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

2017/4/1

Button Fire / Button shoot

1
2
3
danpost danpost

2017/4/2

#
I believe what Hippo was saying is to add a field in your Latar class that the tembak object can alter. The world can check its value to see when the rocket can shoot. Like, in the Latar class, to add:
public boolean canShoot;
in tembak:
public void act()
{
    if (Greenfoot.mousePressed(this))
    {
        Latar latar = (Latar)getWorld();
        latar.canShoot = true;
    }
}
then, in Latar act method:
if (canShoot)
{
    addObject(new Peluru(), roket.getX(), roket.getY());
    canShoot = false;
}
This is quite similar to what you have done with your Button subclasses.
iban iban

2017/4/2

#
oh my Good. thank's thank's thaaank'sss mr.danspor.. this work. very thank's for you. this very work. . i very tried wkwk. thank you MASTER :)
You need to login to post a reply.
1
2
3