I am making a game in which the player has to evade incoming objects, however the objects get stuck on the edge of the word.
Thanks for taking the time to read my question.
public boolean isOffScreen() { if (getX() < 0 - getImage().getWidth()/2 || getX() > getWorld.getWidth() + getImage().getWidth()/2 || getY() < 0 - getImage().getHeight()/2 || getY() > getWorld().getHeight() + getImage().getHeight()/2) { return true; } return false; }
public void act() { if (isOffScreen()) { getWorld().removeObject(this); } //rest of your act code. }
if (getX() == 0) getWorld().removeObject(this);