I've been trying to make an object move left and right when it hits the world border but when it gets the the edge it starts shaking. If someone could tell me how to fix this, that would be helpful.
public void act() { moveLeftAndRight(5); } private void moveLeftAndRight(int direction) { if((direction < 0 && getX()== 0) || (direction > 0 && getX() == 999)){ direction = -direction; } move(direction); }