Hi again, I'm having problems, my problem is when the zombie just hit me once, my health goes down all the way to zero, I'm not sure if it's with the code but here's the code:
public class Person extends Actor { boolean touchingZombie = false; public void act { hitZombie(); } public void hitZombie() { Actor zombie = getOneIntersectingObject(Zombie.class); Actor midget = getOneIntersectingObject(Midget.class); Actor explosion = getOneIntersectingObject(Explosion.class); if(zombie != null) { World myWorld = getWorld(); MyWorld myworld = (MyWorld)myWorld; HealthBar healthbar = myworld.getHealthBar(); if(touchingZombie == false) { healthbar.loseHealth(); touchingZombie = true; if(healthbar.health <=0) { GameOver gameover = new GameOver(); myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2); myWorld.removeObject(this); } } } if(midget != null) { World myWorld = getWorld(); MyWorld myworld = (MyWorld)myWorld; HealthBar healthbar = myworld.getHealthBar(); if(touchingZombie == false) { healthbar.loseHealth(); touchingZombie = true; if(healthbar.health <=0) { GameOver gameover = new GameOver(); myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2); myWorld.removeObject(this); } } } if(explosion != null) { World myWorld = getWorld(); MyWorld myworld = (MyWorld)myWorld; HealthBar healthbar = myworld.getHealthBar(); if(touchingZombie == false) { healthbar.loseHealth(); touchingZombie = true; if(healthbar.health <=0) { GameOver gameover = new GameOver(); myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2); myWorld.removeObject(this); } } } else { touchingZombie = false; } } }