How do I change sprite direction on tap?

Get help using Construct 2

Post » Fri Jul 24, 2015 2:07 pm

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!
B
4
Posts: 5
Reputation: 687

Post » Fri Jul 24, 2015 2:10 pm

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
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Fri Jul 24, 2015 2:33 pm

Alright! Sorry for being so new to this but how do I multiply the variable?
And thanks for the quick response, RayKi!
B
4
Posts: 5
Reputation: 687

Post » Fri Jul 24, 2015 3:10 pm

B
66
S
24
G
7
Posts: 1,515
Reputation: 11,041

Post » Fri Jul 24, 2015 3:26 pm

I see, thanks korbaach!
The support in this community continues to amaze me :-)
B
4
Posts: 5
Reputation: 687


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Jackriduk, kiki4construct and 30 guests