You don't need the Boolean isInvincible in the (). isInvincible should be private. Why don't you put it in act()?


private void checkBossCollision() { if (getWorld() == null) return; Actor a = getOneIntersectingObject(Boss.class); if (a != null) { if (isInvincible) return; lives--; counter.loseLife(); Greenfoot.playSound("catscreech2.wav"); Space space = (Space) getWorld(); space.addObject(new Explosion(), getX(), getY()); space.removeObject(this); if (lives <= 0){ GameOver gameover = new GameOver(); space.addObject(gameover, space.getWidth()/2, space.getHeight()/2); } else { int x = Greenfoot.getRandomNumber(340); space.addObject(new Rocket(), 65, 413); space.addObject(this, 65, 413); isInvincible = true; movement.setNeutral(); } } else { isInvincible = false; } }
private void checkBossCollision() { if (getWorld() == null) return; Actor a = getOneIntersectingObject(Boss.class); if (a != null) { if (isInvincible) return; lives--; counter.loseLife(); Greenfoot.playSound("catscreech2.wav"); Space space = (Space) getWorld(); space.addObject(new Explosion(), getX(), getY()); space.removeObject(this); if (lives <= 0){ GameOver gameover = new GameOver(); space.addObject(gameover, space.getWidth()/2, space.getHeight()/2); } else { int x = Greenfoot.getRandomNumber(340); space.addObject(new Rocket(), 65, 413); space.addObject(this, 65, 413); isInvincible = true; movement.setNeutral(); } } else { isInvincible = false; } }
private void checkCollision() { if (getWorld() == null) return; Actor a = getOneIntersectingObject(Spacedog.class); if (a != null) { if (isInvincible) return; lives--; counter.loseLife(); Greenfoot.playSound("catscreech2.wav"); Space space = (Space) getWorld(); space.addObject(new Explosion(), getX(), getY()); space.removeObject(this); if (lives <= 0){ GameOver gameover = new GameOver(); space.addObject(gameover, space.getWidth()/2, space.getHeight()/2); } else { int x = Greenfoot.getRandomNumber(340); space.addObject(new Rocket(), 65, 413); space.addObject(this, 65, 413); isInvincible = true; movement.setNeutral(); } } else { isInvincible = false; } }