I am trying to code a game and I want my png (character) to face the direction of the movement so I tried to make it flip horizontally everytime I clicked "s" (move left) but it would happen repeatedly and would just keep happening. I only want it to flip once when I click "s".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public void act() { if (Greenfoot.isKeyDown( "d" )) { setLocation(getX()+ 5 , getY()); setRotation( 360 ); } if (Greenfoot.isKeyDown( "a" )) { getImage().mirrorHorizontally(); setLocation(getX()- 5 , getY()); } } |