How do I change sprite direction on tap?

0 favourites
  • 5 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi there!

    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!

  • Instead of 1 and 0, set the values to 1 and -1.

    Every time the player taps the screen you multiply the variable value by -1

  • Alright! Sorry for being so new to this but how do I multiply the variable?

    And thanks for the quick response, RayKi!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I see, thanks korbaach!

    The support in this community continues to amaze me

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)