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:
in tembak:
then, in Latar act method:
This is quite similar to what you have done with your Button subclasses.
public boolean canShoot;
public void act()
{
if (Greenfoot.mousePressed(this))
{
Latar latar = (Latar)getWorld();
latar.canShoot = true;
}
}if (canShoot)
{
addObject(new Peluru(), roket.getX(), roket.getY());
canShoot = false;
}
