How do I make a button clickable only exactly when displayed

Get help using Construct 2

Post » Mon Sep 07, 2015 4:03 pm

Message: haruhi4 is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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?
B
5
S
1
Posts: 27
Reputation: 425

Post » Mon Sep 07, 2015 4:50 pm

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
B
5
S
1
Posts: 27
Reputation: 425

Post » Mon Sep 07, 2015 6:58 pm

@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.
ImageImageImage
B
27
S
16
G
82
Posts: 1,029
Reputation: 45,777


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests