How do I make a button clickable only exactly when displayed

0 favourites
  • 3 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • I am developing a construct2 game. I want a button that only appears when a popup window is shown, to be only clickable when this window is showing. I have tried to make a condition: "on layer visible" on the events referring to the click... didn´t work. I have tried to create a global variable "popup_is_showing" and work with that... still don´t work. I have tried to make only the object(not the layer) invisible at the start of layout and visible only when the popup appears... still not working! When i debug my game, i see that the status of visibility of my button is 0, which means it is visible. I have also tried

    to move the button to an impossible Y(like 99999) when the popup is not appearing and moving it to normal location when the popup is showing... still not working.

    My popup is a different layer with many objects.

    I have already read this post:

    And still my button which stands on a "popup_menu" layer is still clickable.

    What else can i do to make my button only clickable when the popup window is showing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have found the best solution. It was hard to achieve, but worth it.

    -Create a global variable called "time_until_popup_showed". It´s innitial value is -1.

    -When the popup should open(or a layer should be made visible), make the value of this global variable be 0.

    -In all conditions that have something to do with the button/image/object you dont want to be touched unless the popup is appearing, put the condition: "time_until_popup_showed > 0"

    -Make an event that is triggered every 1 second and time_until_popup_showed > -1 to make the global variable be added by 1(time_until_popup_showed will be time_until_popup_showed + 1)

    • If you made the user click somewhere (a button maybe) to open the popup/new layer, make this button invisible when you touch it(to make the popup open) and add this condition to its touch: button is visible
    • when you want to make the popup disappear, don´t forget to set the time_until_popup_showed to -1 and the button cited above(the one that opens the popup) to visible
  • haruhi4 it all sounds like a cannon for a fly. There are many (more simple) ways to make a button active or not. Let me point few from the top of my head:

    1. Create "isClickable" instance variable for the button. Switch value between 0/1 whenever you want to enable or disable buttons functionality (you can do the same for the whole family of buttons). Then your condition should be

    "onClick on button AND button.isClickable = 1" => do something.

    2. You can surely do the same with the layer visibility condition if you have whole popup on one layer, so it would be:

    "onClick on button AND popupLayer is visible" => do something.

    3. You might also want to create whole popup functionality within one group, then you can simply activate or deactivate the gorup which will enable or disable "onclick" functionality you put there.

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