how do I toggle stop and go

Just started using Construct 2? Post your questions here

Post » Fri Feb 06, 2015 4:55 am

I have a sprite that is constantly moving forward, and I want to click it to stop it, and click it again to make it move again, and I can't get it to work for the life of me! I've been messing with values and boolians and i can't figure it out.. this should be easy :oops:
B
14
S
4
G
1
Posts: 32
Reputation: 1,437

Post » Fri Feb 06, 2015 5:50 am

Give the sprite an instance variable called something like "Moving" which stores a boolean value. Set it's default to true. When the toggle action happens, set it to false when it is true and use a System Else event to Toggle it back to true. You need to use the Else event so it doesn't just immediately switch back to the previous state.

Capture.PNG


A lot of times, people try to just say, if true set false, if false set true but what this does is, when the event triggers for true, it sets the value false and since right after setting it false, it checks to see if it is false it triggers the second event setting it right back to true.
You do not have the required permissions to view the files attached to this post.
B
38
S
12
G
11
Posts: 331
Reputation: 7,712

Post » Fri Feb 06, 2015 6:41 am

thank you so much! I've seen the else event before.. but I cant remember how I got it to appear.. is there something I'm missing?
B
14
S
4
G
1
Posts: 32
Reputation: 1,437

Post » Fri Feb 06, 2015 6:45 am

nevermind found it, thanks again!
B
14
S
4
G
1
Posts: 32
Reputation: 1,437


Return to Beginner's Questions

Who is online

Users browsing this forum: the_Shit_hawk and 0 guests