Turn a switch on or off

  • This must be first grade, but either I don't understand the concept or I don't know what's going on.

    I created a square sprite, the idea is that if you press it, it changes to frame 1 which is blue and if you hit it again, it returns to frame 0.

    To manage it I created a boolean variable called "on".

    I thought it would be as simple as doing it this way:

    That I play the sprite and the Boolean is fake? So I turn it on and frame 1. Then it's true? Well, when you click it does the opposite.

    But when you execute, the switch is ON and it doesn't go back to false.

    Another thing, if I change the order of System is on and System X is On it doesn't do the same, it doesn't even turn ON anymore.

    Such a relatively simple thing and I don't see the problem.

    I'm sure it's something totally silly. I know I could use "else" and it would work. But I don't understand why not, and why changing the order makes it even worse.

    Thanks a lot

  • Perhaps the Switch Objects animation speed is something other than "0"?

  • Perhaps the Switch Objects animation speed is something other than "0"?

    No, the animation speed is 0.

    Here the c3p:

    drive.google.com/file/d/1Xsychg2HeLnXuLeBMG8fYGQsWuW_emmw/view

  • You should use toggle boolean.

    Then set the animation equal boolean value.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should use toggle boolean.

    Then set the animation equal boolean value.

    Much cleaner that way. But if I want to put a set text on/off, I can't do it like that.

  • the problem is that event 2 checks if the switch is on, if so then turn it off.

    then event 3 checks if it is off and then turns it right back on.

    event 3 should be an Else statement so it will only run if event 2 is false.

  • the problem is that event 2 checks if the switch is on, if so then turn it off.

    then event 3 checks if it is off and then turns it right back on.

    event 3 should be an Else statement so it will only run if event 2 is false.

    Thanks at all! I didn't exactly understand how it worked, but I just did.

  • Much cleaner that way. But if I want to put a set text on/off, I can't do it like that.

    You can check if ON = true -> set text to "ON" and same false for "OFF"

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