Need help getting my actor to shoot one laser at a time as opposed to 4 or 5 at once.
Here's my code:
public class JayLaser extends Actor
{
public JayLaser()
{
GreenfootImage image = getImage(); // Setting the image (which is the GIHS logo)
image.scale(50,50);
setImage(image);
}
public void act()
{
setLocation(getX() - 5, getY()); // Laser shoots from left of player
if (isTouching(Hakim.class)) // If laser touches opponent
{
World myWorld = getWorld();
MyWorld myworld = (MyWorld)myWorld;
Counter counter = myworld.getCounter();
counter.loseHealth(-1); // The opponent's counter loses health
getWorld().removeObject(this); // And the laser is removed from the world
}
}
}

