0 Favourites

How do I make a (settings) toggle switch button?

  • Hello. I already made a toggle switch button: (consists of 5 sprites; settings button, blue bar, info, sound & music).

    I've managed to make the blue bar and the other items pop-up after the settings button is clicked.

    However, I am struggling at making it disappear once you re-click again.

    I've tried and didn't work:

    1. Making a global variable (Settings_Clicked) with default value of 0. When the settings button is clicked, the value changes to 1. Afterwards, if the value is 1 and there's a click on the settings button then the rest of the items will be invisible.

    2. Make 2 settings buttons sprites. The primary one (when not clicked) would be visible until it's clicked. Once it's clicked, it will become invisible and the secondary button will appear among with the rest of the items. Once the secondary button is clicked, the button itself and the popup will be hidden and the primary button will be visible again.

    Please advice. I switched from native iOS Swift development and Stencyl to Construct 2 and I am having a bit of hard time understanding its programming mechanics.

  • Many ways to do this..

    One way is to give the settings button an instance variable boolean "active"

    on settings clicked

    toggle boolean variable

    -- settings is boolean

    set sprites visible

    -- settings is not boolean

    set sprites invisible

    Also using an else statement could be used for this and many other things..

    If instead of setting visible you create and destroy the rest of the sprites, you could prevent the possibility of clicking them, instead of having to add extra conditions for that..

  • Hello. I already made a toggle switch button: (consists of 5 sprites; settings button, blue bar, info, sound & music).

    I've managed to make the blue bar and the other items pop-up after the settings button is clicked.

    However, I am struggling at making it disappear once you re-click again.

    I've tried and didn't work:

    1. Making a global variable (Settings_Clicked) with default value of 0. When the settings button is clicked, the value changes to 1. Afterwards, if the value is 1 and there's a click on the settings button then the rest of the items will be invisible.

    2. Make 2 settings buttons sprites. The primary one (when not clicked) would be visible until it's clicked. Once it's clicked, it will become invisible and the secondary button will appear among with the rest of the items. Once the secondary button is clicked, the button itself and the popup will be hidden and the primary button will be visible again.

    Please advice. I switched from native iOS Swift development and Stencyl to Construct 2 and I am having a bit of hard time understanding its programming mechanics.

    If you attach a capx example I can implement the rest for you ;=)

  • I prefere to make toggles like that:

  • I prefere to make toggles like that:

    If you use that, why not just use:

    on left button clicked

    set Toggle = 1-Toggle

  • > I prefere to make toggles like that:

    >

    >

    >

    If you use that, why not just use:

    on left button clicked

    > set Toggle = 1-Toggle

    Didn't thought about that, it's even more simple. Thanks!

  • Hello everyone. At the end of the day, I used a combination of the recommended solutions (thanks guys) and it worked out.

    Settings_Switch is a global variable

    Here's the preview:

  • Hello everyone. At the end of the day, I used a combination of the recommended solutions (thanks guys) and it worked out.

    Settings_Switch is a global variable

    Here's the preview:

    Yep, that will work..

    You could remove the Settings_Switch > 1 event and make the action of the first event

    system set Settings_Switch = 1 - Settings_Switch

    It's one event less..

    Also I'd make the third an fourth event subevents of the top-event, because they only have to be checked at the time of the toggle..

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • > Hello everyone. At the end of the day, I used a combination of the recommended solutions (thanks guys) and it worked out.

    >

    > Settings_Switch is a global variable

    >

    > Here's the preview:

    >

    >

    Yep, that will work..

    You could remove the Settings_Switch > 1 event and make the action of the first event

    system set Settings_Switch = 1 - Settings_Switch

    It's one event less..

    Also I'd make the third an fourth event subevents of the top-event, because they only have to be checked at the time of the toggle..

    Thank you for the advice. Still learning Construct 2 event sheet feature and your help is outstandingly great and very much appreciated.

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