Here is my act method:
public void act()
{
move();
checkKeys();
checkCollision();
checkBossCollision();
reloadDelayCount++;
if(delay == 10)
{
isInvincible = false;
}
else {
delay++;
}
}
And the collision method:
private void checkBossCollision()
{
if (getWorld() == null) return;
Actor a = getOneIntersectingObject(Boss.class);
if (a != null)
{
if (isInvincible=false)
{
int x = Greenfoot.getRandomNumber(340);
lives--;
if (lives <= 0){
Space space = (Space) getWorld();
space.addObject(new Explosion(), getX(), getY());
space.removeObject(this);
GameOver gameover = new GameOver();
space.addObject(gameover, space.getWidth()/2, space.getHeight()/2);
}
counter.loseLife();
Greenfoot.playSound("catscreech2.wav");
Space space = (Space) getWorld();
space.addObject(new Explosion(), getX(), getY());
space.removeObject(this);
isInvincible = true;
space.addObject(new Rocket(), 65, x);
space.addObject(this, 65, x);
movement.setNeutral();
}
}
}
At the top I put the private int delay = 0;
But now the collision method doesn't seem to be working at all?

