This site requires JavaScript, please enable it in your browser!
Greenfoot back
Al7amed
Al7amed wrote ...

2014/3/26

Shooting Left and other things

Al7amed Al7amed

2014/3/26

#
anybody can help me about shooting left http://www.greenfoot.org/scenarios/11168 also how can I upload without lock .. I mean everybody can play it and download it
danpost danpost

2014/3/26

#
In the 'Share' window, there is a checkbox with the words 'Publish source code'. Check it before uploading and the lock is removed.
danpost danpost

2014/3/26

#
You will have to be more specific about the shooting. Post the class of the Actor that shoots. Use the 'code' link below the 'Post a reply' box to insert your code.
Al7amed Al7amed

2014/3/27

#
I put it already you can download it and see the problem or from here
public boolean shooting()
    {
        if(Greenfoot.isKeyDown("space") && shootingCounter <= 0 && direction == 1)
        {
            getWorld().addObject( new SilverBullet(), getX(), getY());
            shootingCounter = 20;
            return true;
        }
        else if(Greenfoot.isKeyDown("space") && shootingCounter <= 0 && direction == -1)
        {
            getWorld().addObject( new SilverBullet(), getX(), getY());
            shootingCounter = 20;
            return true;
        }
        return false;
    }
danpost danpost

2014/3/27

#
If you change your 'fly' method in the SilverBullet class to this:
private void fly()
{
    move(shootingSpeed);
}
you can then change your 'shooting' method in the SilverSonic class to this:
public boolean shooting()
{
    if (shootingCounter > 0 || !Greenfoot.isKeyDown("space")) return false;
    Actor sb = new SilverBullet();
    if (direction == -1) sb.setRotation(180);
    getWorld().addObject(sb, getX(), getY());
    shootingCounter = 20;
    return true;
}
Al7amed Al7amed

2014/3/27

#
Thank you man .. its work now
You need to login to post a reply.