How do toggle sprite visibility on and off?

0 favourites
  • 6 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • I start a layer with an invisble sprite, once tapped it becomes visible and the next tap it should become invisible again.

    This is what I have so far...

    So when it's touched, and also the variable is 0 then it should become visible and set the variable to 1

    on next touch if the variable is 1 then it should go invisible and re-set the variable back to 0

    This doesn't work and I can't work out why.

    I did find a variety of instructions for Construct2 but they all seemed more complicated than neccessary...

    Any ideaS?

  • Use sub-events, a single condition "Tap gesture" and then in the sub-events you can check the value of speakerviz.

    In the second sub-event (when you check if the value is =1) use the system condition "Else".

    Currently, when your value is 0 the first event is executed, changing the value of speakerviz to 1.

    Then right away, it is checking if the value of speakerviz is = 1.

    It is.

    So it sets it back to 0.

    In the same tick, the sprite is set to be visible and invisible.

    The last one being invisible, you are under the impression it never changes, when it actually does. Once. Inside a tick of execution.

  • Thank you, I guess I still don't quite get how the sub-conditions work and where "Else" can be used

    Sorry, I know this is really simple but it hasn't clicked yet.

    Can anyone upload a screen shot so I can see how it's meant to flow in the editor?

  • The "Else" must be at the same level then "spearkerviz = 0", not a sub-event of it.

  • thank you, I also managed to make it work without 'else' now, which i'm sure is less efficient... i'll try the way you described again

    This is the working method I have currently:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • An easier way...

    Basically subtracting speakerviz from itself, causing a toggle.

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