In my game I have a gif that walk back and forth with a speed of 1, and when it hits a wall the gif changes it speed to -1. How can I make my gif flip it self when it changes speed to -1 and stay that way until it changes it speed again.


if ((speed == -1 && getX() < 10) || (speed == 1 && getX() > getWorld().getWidth()-10)) { getImage().mirrorHorizontally(); speed = -speed; }
if ((speed == -1 && getX() < 10) || (speed == 1 && getX() > getWorld().getWidth()-10)) { getImage().mirrorHorizontally(); speed = -speed; }
if (speed < 0) getImage().mirrorHorizontally();
if (speed < 0) getImage().mirrorHorizontally();
public void mirrorImagesHorizontally() { for (int i=0, i<images.length; i++) images[i].mirrorHorizontally(); }
if ((speed == -1 && getX() < 10) || (speed == 1 && getX() > getWorld().getWidth()-10)) { speed = -speed; mirrorImagesHorizontally(); }
public void mirrorImagesHorizontally() { for (int i=0, i<images.length; i++) images[i].mirrorHorizontally(); }
if ((speed == -1 && getX() < 10) || (speed == 1 && getX() > getWorld().getWidth()-10)) { speed = -speed; mirrorImagesHorizontally(); }