I'm trying to make an actor disappear when it hits the right edge of the screen. I wrote the code to do so but for some reason it is not disappearing when it hits the edge. Here's the code:
public void act()
{
int xpos=getX();
if(xpos<600)
{
xpos = xpos +5;
setLocation(xpos,getY());
Actor rock = getOneIntersectingObject(Astroid.class);
if(rock != null)
{
hit();
getWorld().removeObject(rock);
getWorld().removeObject(this);
}
}
else if(xpos> 600)
{
getWorld().removeObject(this);
}
}
public void hit()
{
AstroidWorld World = (AstroidWorld) getWorld();
Counter counter = World.getCounter();
counter.increaseScore(10);
}

