0 Favourites

Prevent any other activity while variable is set

  • 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.

  • + 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
  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Yann to the rescue. Thanks man, will try this as soon as I wake up tomorrow.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
88 9,238
goldentreee's avatar
goldentreee
Unread hot topic
64 12,940
trollface's avatar
trollface
Unread hot topic
41 3,218
Napelazam's avatar
Napelazam