Disable invisible layer

Discussion and feedback on Construct 2

Post » Wed Jan 07, 2015 5:59 am

I want to use a pause window that has: Play, restart and Level buttons.
I put this "window" with buttons (sprites) into a layer.
I let this layer invisible and turn it visible when click the mouse sprite.

The problem is, even invisible, I can click on the buttons (sprites with mouseClick event).

Any help or idea?
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Wed Jan 07, 2015 6:25 am

put those pause layer events as a subevent for and event the has the condition Layer is visible
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Wed Jan 07, 2015 6:26 am

Put the click events into a group and enable/disable that as needed.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Jan 07, 2015 9:50 am

That's the right way to go. It may seem strange that buttons are clickable when the layer is invisible, but that's normal (invisible doesn't mean inexistant).
You need to tell the engine you don't want it clickable when hidden.
For that you can make a group and then a main event inside looking : Is my menu layout visible or not ? Then all the actions / events.
... "Je suis CHARLIE" ...
B
30
S
6
G
2
Posts: 43
Reputation: 2,075

Post » Wed Jan 07, 2015 9:56 am

Yeah, the group approach is also good because it teaches you good form according to the Manual - you can disable entire sections of the game if they aren't used thus improving performance.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Jan 07, 2015 10:17 am

Here is a Capx i have done for you to test.
By pressing " i " you can switch the visibility of the two buttons (it's the same logic if you ask if it's a sprite visibility or Layout / layer). The red button is clickable even when hidden (that's not what we want) but the blue one is only clickable when visible. And this, because i said : If button blue isn't visible then deactivate the group (where all the actions for the blue button are), this way you can easily make many actions, for various buttons inside a single group and deactivate the whole thing by only doing one check (the visibility).
You do not have the required permissions to view the files attached to this post.
... "Je suis CHARLIE" ...
B
30
S
6
G
2
Posts: 43
Reputation: 2,075

Post » Wed Jan 07, 2015 10:31 pm

Thanks all.
I´ve already read about Enable/disable groups but had never used before.
it worked.

Thanks Softloulou for the example!
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Sun Dec 20, 2015 1:31 am

One other thing to be aware of, because this was driving me insane. Let me know if there's a better way though. I was struggling with all of the suggestions of checking the conditions of a layer's visibility in order to see if a mouse click was valid. None of the methods worked for me so I saw this post, was excited, and realized this didn't work either.

I found out my problem was that I set the Group back to Activated too quickly. Therefore the underlying button that I didn't want to get clicked would get respond, because the condition I set was already true. To remedy this, I put a timer on the Event Sheet. Every second it checks for my condition, and if it is true, it reactivates the Group. I believe what this is doing is waiting past the next game cycle before determining if we should reactivate the Group or not. It is now working. Let me know if you need more explanation on this.
B
8
S
2
Posts: 4
Reputation: 526

Post » Sun Dec 20, 2015 1:44 am

if you put the condition in the "root" of the eventsheet didn't work? Theoretically, it passes through it every tick.
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Fri Jan 13, 2017 5:34 pm

Hi, i have a similar difficulty. I have a layout with a global layer. Inside this global layer a "pause menu". And in the other layouts i have layers with the same name of that layer that have "global: (Yes, overridden)".
When i go to menu or other screens and i click on the place where is supposed to be this pause menu i want that nothing happens until i press the "pause" button, but the pause menu is active when invisible.
I have an event group for the pause menu in his event sheet, and i tried different ways for deactivating it, but i can't.

How i deactivate this global layer when not visible?

Regards, Avengium.
B
8
Posts: 5
Reputation: 312

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Solomon and 3 guests