Can someone please tell how to shoot something out of an actor
private int bulletTimer = 0;
public void act()
{
//...
shoot();
}
public void shoot()
{
if (bulletTimer < 50) //delay: smaller number = shoots faster
{
bulletTimer++;
return;
}
if (Greenfoot.isKeyDown("space")) //shoots with the spacebar
{
Bullet b = new Bullet(); //or however you call the class
getWorld().addObject(b, getX(), getY());
b.setRotation(getRotation());
b.move(5);
bulletTimer = 0;
}
}