How do I Prevent Click Through Object [Solved]

0 favourites
  • 10 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Dear,

    I want to build a confirmation dialog as player click on a Reload button (I call it layer A - Show picture with Exit, cancel buttons) to return 1st layout.

    Do you know how to prevent click through layer A (prevent affect items clickable under layer A)?

    Thanks!

  • I personally use a finite state machine for this. Basically you have a global variable that changes depending on the current state of your app. In your case you have two states, the "normal" state and the "confirm_dialog" state. Once the confirm dialog shows you change the global variable to "confirm_dialog" and check the condition of the variable.

    http://gameprogrammingpatterns.com/stat ... the-rescue

  • Thanks! However this is could not be applied to my game due to its complicated (could not control with only 1 variable SWITCH).

    I need to learn how to make anti-click through objects in Construct 2!

  • Just add a condition on the buttons on the layer under the active layer.

    For example:

    On button Pressed ------------> do something

    layer A is not visible

    Add a regular "layer is visible" condition and right click on it and invert it or press "i".

    You can also do the same on the events for the buttons on layer A but they should of course just work when layer a is actually visible.

  • Anonnymitet: I understand that by using toggle layer vissible/invisible I can toggle a dialog (layer A). However, what I want is prevent click through this layer (layer A display at center of current game screen)...

  • As I said, you should set a condition to all buttons to make them not clickable when they are not in focus. There are tons of ways to prevent that. But the way I showed you should work just fine.

    So on the buttons that you don't want to be clicked under layer A. Give those a condition that makes them only clickable when layer A is NOT visible and they can not be clicked under your dialogue box

  • Anonnymitet: Thank you! I do not understand you clearly on the previous comment. It is what I need!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No problem, glad you got it working. Good luck with your project

  • For the windows in my project I am using a system that requires one global variable - window_Level, and an instance variable window_Level for every object (buttons, images etc.) that I am displaying in windows (add them in a family and make one instance variable for all).

    So, every time you open a window, raise the global window_Level by 1 and set the instance variable window_Level to the new level for all objects of that window.

    Once you click a button, check if the button instance variable is equal to the global.

    Also, don't forget to reduce the value when closing a window.

  • RobertMKD: Great approaching method! Thank you!

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