My actor gets removed from the world after its healthbar is up but it says "Actor not in world" as soon as the healthbar is up. The healthbar itself is working, it's just that the game stops after the actor gets removed from the world.
Bullets:
How can I fix it?
boolean touchingEnemy = false;
public void act()
{
move(10);
checkEnemy();
}
public void checkEnemy()
{
Actor enemy = getOneIntersectingObject(Enemy.class);
if(enemy != null)
{
World myWorld = getWorld();
MyWorld myworld = (MyWorld)myWorld;
HealthBar healthbar = myworld.getHealthBar();
if(touchingEnemy == false)
{
healthbar.loseHealth();
touchingEnemy = true;
if(healthbar.health <= 0)
{
myWorld.removeObject(enemy);
}
}
}
else
{
touchingEnemy = false;
}
}
