How do I limit mouse controls to topmost object?

0 favourites
  • 4 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Example: I have a button that creates a window on layer "UI". I have a sprite that reveals an object on layer "Game" (below UI layer) when mouseovered. If the window is over the sprite, mousing over the sprite will reveal that object above the window. Thus, I'll see a random object obstructing my UI layer.

    Example: I made a simple camera control setting based on clicking over the map and dragging. If I click this window and try to move it, I also trigger the camera function because the mouse is over the map, even though the window is in the way.

    Example: I have a button that creates this window. I also allow the same button to destroy the window. If I move the window over the button to hide it, then click the button, the button still counts as clicked and destroys the window.

  • The first example shouldn't be happening if the sprite object is on a layer below the UI layout. I would guess it's somehow getting moved, or created, on the same layer as the UI.

    For the second example I would try to include a condition for the camera scrolling function that doesn't trigger it if the mouse is overlapping/dragging the window. I.e. "if click and drag + not dragging window -> move camera", This should stop the camera from scrolling if the window is being moved.

    For the third example I'd try something similar to the second. "If button clicked + mouse not clicking window -> destroy window". This way if the button is obscured by the window, clicking in that area shouldn't push the button.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One good way of handling modal UIs is to group actions that handle different "layers" into different event groups, and disable/enable them depending on what is showing. So if you have events for your main game, you disable them while the pause menu is showing, and re-enable them when you close it, for example.

  • tgfcoder That sounds like a great idea, Thanks!

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