How to toggle a sprite via double clicking (animation frame 0 to animation frame and back to 0)

0 favourites
  • 4 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • I wrote what seemed a straightforward solution to toggle a sprite's appearance.

    A mouse double click on the sprite, with an additional condition that the animation frame of said sprite is zero, sets the animation frame to 1, and another double click event with the condition that the animation frame is set to 1, sets it to 0.

    However, for some reason both both are executed at a single loop, causing no toggle behavior.

    Its as if the double click is remembers between the event checks.

    What I really, want is to have N number of created sprites and double clicking on one, selects it with a frame, and de-selects all others.

    But, i am stumped ...

  • The formula is abs(Sprite.AnimationFrame-1) or (Sprite.AnimationFrame+1)%2.

  • Thanks.

    I used at one point the formula 1-sprite.animationframe,

    And it works well so long i only have one event(doubleclick, sprite), action line defined. If i have two event line items then the second cancels the first immediately.

    But, to deselect all the rest upon a same double click event, I need to have a second event that only executes when the animation frame was already changed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ok, I figured it out :-)

    Required storing a UID of the toggled sprite, and then loop through all via a family and set frame to 0 for all but the one sprite with the stored UID in the global.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)