Reset state of button after 2th click

Get help using Construct 2

Post » Sat Aug 04, 2012 1:51 am

I got big problem when I want to reset value of Global variable and Button text.
My purpose:
1. In initial time, my Button have text = "Start" and Global variable isMoving == 1.
2. After first click my Button must have text = "Stop" and Global variable isMoving is reset to isMoving == 0.
3. After second click my Button must have text = "Start" again and Global variable isMoving must be equal 1.

But actually, when program is launched, my Button text == "Start" after few clicks..?? and I guess my Global variable isMoving == 0....

Could some one help me pls. Because very specific purpose I could use only one button.

My program like below

Global number isMoving =1
Button     |     On clicked
          (if)     System|isMoving = 0 -->Button|Set text to "Stop"
                    -     -->System|Set isMoving to 1
          (else)     System|isMoving = 1 --> Button|Set text to "Start"
                         -->System|Set isMoving to 0hoanganh172012-08-04 01:55:21
B
11
S
2
Posts: 73
Reputation: 1,438

Post » Sat Aug 04, 2012 2:02 am

Ive had this happen to me. I usually put a 0.1 or 0.5 second delay after the click is executed. Whats happening is if you click its checking to see if the variable is 1. Once you click it changes into 1 instantly and doesn't know you want it to toggle. Its instant. Try putting in a delay in there.
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sat Aug 04, 2012 2:33 am

Dear AarongamerX
Thank so much for your quick reply
I change my program like that, but same result..??

Where I must put System.DelayTime ???

Global number isMoving =1
Button|On clicked -->System|wait 0.5 seconds
          [SubEvent](if)     System|isMoving = 0 -->Button|Set text to "Stop"
                    -     -->System|Set isMoving to 1
          [SubEvent](else)     System|isMoving = 1 --> Button|Set text to "Start"
                         -->System|Set isMoving to 0
B
11
S
2
Posts: 73
Reputation: 1,438


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 28 guests