Prevent any other activity while variable is set

Get help using Construct 2

Post » Fri Mar 02, 2012 12:49 pm

In my event sheet I have 2 clickable objects. Sprite A and Sprite B

When you click on one of them spriteC starts moving up the screen an ajax call is triggered and a global variable called isMoving gets set to 1.

When the ajax call is completed the sprite changes direction until it gets back to its start position. At this point isMoving gets set back to 0.

The movement action is the same when both spriteA or spriteB are clicked but the ajax call is different.

My problem is that when I click sprite A and trigger spriteC's movement and ajax callA I can still click on spriteB which triggers spriteC's movement and ajax callB.

I would like to make sure that:
While isMoving == 1
SpriteA and SpriteB are not Clickable

Any pointers would be appreciated.
B
16
S
2
G
4
Posts: 67
Reputation: 3,295

Post » Fri Mar 02, 2012 10:05 pm

[code]+ System: isMoving = 0
+ Mouse: on Left Click on SpriteA
    -> System: set isMoving to 1
    -> Ajax: request [spritA call] tag:"myCall"
+ Mouse: on Left Click on SpriteB
    -> System set isMoving to 1
    -> Ajax: request [spritB call] tag:"myCall"
+ System: isMoving = 1
-> SpriteC: move
+ Ajax: on completed "myCall"
-> System: set isMoving to 0
// And to not get stuck
+ Ajax: on error "myCall"
-> System: set isMoving to 0[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Mar 02, 2012 10:16 pm

Yann to the rescue. Thanks man, will try this as soon as I wake up tomorrow.
B
16
S
2
G
4
Posts: 67
Reputation: 3,295


Return to How do I....?

Who is online

Users browsing this forum: Skebab and 13 guests