Disable invisible layer

0 favourites
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • 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?

  • put those pause layer events as a subevent for and event the has the condition Layer is visible

  • Put the click events into a group and enable/disable that as needed.

  • 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.

  • 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.

  • 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).

  • Thanks all.

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

    it worked.

    Thanks Softloulou for the example!

  • 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.

  • if you put the condition in the "root" of the eventsheet didn't work? Theoretically, it passes through it every tick.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another way of doing this, if you dont want to use groups, is to create a family where you put those 3 buttons and you can enable/disable collision. This is how I've done and it works fine.

  • All you have to do to make invisible buttons work is have a parent event that says

    "layer 1 is visible"

    (sub event)------> on button click -> do stuff

  • When using a global layer. Can do this too.

    https://www.dropbox.com/s/xm8z6dd2mrmyy ... .capx?dl=0

    If you build the Menu with only sprites, (eventual using rex_Button) it can be done in 2 lines, using 1 family.

    But, besides that, event groups do work flawless. If you need to know what you did wrong, then show what you did.

  • Avengium, Did you import the eventsheet that activate/deactivate and take care of the "pause actions" of the global layer in all eventsheets of the other layouts?

  • anty21ro, justifun, 99Instances2Go frcol Thanks for your answers.

    I forgot about this post so i read this today.

    I resolved my problem making a variable for visible/invisible (sprites) and another variable for blocked/unblocked (group of events). So i update the two variables, and when i close the "pause menu" i update the visibility and the block.

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