How do I change animation based on tap?

Get help using Construct 2

Post » Wed Sep 09, 2015 10:17 pm

once the player changes an animation it does not change back. I want to make it so on tap sets animation to "1" and when I tap a second time it should set animation to "0" and vice versa
B
4
Posts: 5
Reputation: 212

Post » Thu Sep 10, 2015 7:39 am

RedCrumbs wrote:once the player changes an animation it does not change back. I want to make it so on tap sets animation to "1" and when I tap a second time it should set animation to "0" and vice versa


Check it

http://www.filedropper.com/animationchange
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 10, 2015 3:25 pm

have a variable on the sprite, so on click the variable is added or subtracted.
then have animation play on variable = 0, or 1
add a wait function after. otherwise it can be prone to doing both actions on click

on touch, sprite ___________ set variable =1
sprite.variable = 0 _________ wait 0.2 seconds

on touch, sprite ____________ set variable =0
sprite.variable = 1 __________wait 0.2 seconds

this should allow multiple instances of clicks too!
B
9
S
3
Posts: 113
Reputation: 1,009

Post » Thu Sep 10, 2015 3:44 pm

Aher0 wrote:have a variable on the sprite, so on click the variable is added or subtracted.
then have animation play on variable = 0, or 1
add a wait function after. otherwise it can be prone to doing both actions on click

on touch, sprite ___________ set variable =1
sprite.variable = 0 _________ wait 0.2 seconds

on touch, sprite ____________ set variable =0
sprite.variable = 1 __________wait 0.2 seconds

this should allow multiple instances of clicks too!


It would be even easier to use a boolean variable and toggle it on tap..

Or if you want to use a number

on touch sprite - set variable1 = 1-variable1

which would result in a toggle..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Sep 10, 2015 5:19 pm

I forgot to add
sprite.variable=0 ________ play animation

sprite.variable=1________play animation1

also, could just do

on click/touch sprite__________________play animation1
animation default is playing

on click/touch sprite__________________play default
animation animation1 is playing


LittleStain: you are right, however if you wanted more than 2 animations to cycle through. a Boolean wouldn't cut it
B
9
S
3
Posts: 113
Reputation: 1,009


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests