How do I make an image switch, so each time I click it, a certain sprite becomes visible?

0 favourites
  • 5 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • I am trying to make a game in wich the player is supposed to enter 4 images in a certain order. I was first trying to simply make it work, but I couldn't even get 2 sprites to alternately be visible and invisible.

    If I just run event 1, everything is fine: the switch does turn the blue sprite invisble and the red one visible.

    But I would like it to also be able to turn back. So I made event 2, to do the exact opposite.

    But when I run event 2, the switch doesn't even turn de the blue sprite invisble and the red one visible like it did before. It does nothing.

    Can someone please help me?

    The original idea was to make the visible sprite the switch itself, but I gave up on that idea since I could not even get this to work...

  • Create a boolean and just when you press the button toogle the boolean.

    Then add 2 lines if boolean is true visible and if false invicible.

  • Here:

  • The problem is that the second trigger overwrites the changes made by the first trigger in the same tick.

    This is what is happening in one tick:

    1) Click

    2) If blue is visible, set blue to invisible and red to visible

    3) If red is visible, set blue to visible and red to invisible

    You can see that the third step is undoing the changes of the second step.

    What you need to do is have only One click trigger, check for the visibility of one of your objects in a Sub event of the trigger and finally have an ELSE block for that sub event.

    If you do it that way only one set of actions will be executed with each click, instead of both.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! I fixed it :)

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