if(getX() < int || getY() < int || getX() > int || getY() > int) I think this will fix your bullet. the ints are the size of your map just put it in your act method then put under it { getWorld().removeObject(this); }
I've had this problem several times, I found that the getWorld().removeObject(this); statement has to be the very last statement in the act() method or put an if statement that would be false if it's no longer there, here is the reason, the act() method will always executes all statements in it and you get the error if the actor is gone before the act() method is done
here is how I fixed the error:
public class Bullet extends SmoothMover
{
private boolean remove = false;
public void act()
{
movearound();
dissapear();
eatAsteroid();
if(remove)
getWorld().removeObject(this);
}
public void dissapear()
{
if (atWorldEdge())
{
remove = true;
}
}
public void movearound()
{
move(7.0);
}
public void eatAsteroid()
{
if(canSee(Asteroid.class))
{
eat(Asteroid.class);
remove = true;
}
}
}
Also:
public void act() {
if(condition) {
getWorld().removeObject(this);
return;
}
//Any code here won't raise errors if the actor is removed, because the code exits out of the method through the return statement.
}
Have the rocks kill nyan cat.
public void killNyanCat(Class clss)
Actor actor = getOneObjectAtOffset(0,0,clss);
if(actor != null)
{
getWorld().removeObject(actor);
}
this is the method signature:
killNyanCat(NyanCat.class);
2012/5/2
2012/5/2
2012/5/3
2012/5/3
2012/5/3
2012/5/3
2012/5/3
2012/5/3