I am trying to figure out how to change the direction of my sprite.
In the game the player character is always running at the bottom of the screen, changing direction whenever he hits the layout edges. Now, he needs to also change direction whenever the player taps the screen. What I have done so far is creating an instance variable called direction and then have the sprite run to the right whenever the variable is equal to 0 and to the left when it is equal to 1.
I've tried changing the value of the direction variable on tap based on the current value of it, so that on tap subtracts 1 if the value of direction is equal to 1, and adds 1 if the value of direction is equal to 0.
This seems to work perfectly but I can not make the on tap event both add and subtract from the direction value, or can I?
Thank you for taking the time to read this!