For some reason during my asteroid game when the asteriod hits the Player it is supposed to remove the player and stop the Greenfoot game using if (isTouching(Player.class) and removeTouching(Player.class); but when the Asteriod hits the player nothing happens it just phases through the player.
public class Player extends Actor
{
/**
* Act - do whatever the Player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int timer;
public void act()
{
if (Greenfoot.isKeyDown("right"))
{
turn(5);
}
if (Greenfoot.isKeyDown("left"))
{
turn(-5);
}
if (timer > 0) timer--;
int x = getRotation()-360;
if (timer == 0 && Greenfoot.isKeyDown("space"))
{
timer = 50;
getWorld().addObject(new Lazer(getRotation()),getX(),getY());
}
}
}
