Hello!
When developing my game, I ran into a problem: How can I properly check the mouse event for my UI? For example if I want to click on the map, then I dont want the game to handle that click, just only the UIHandler. Or closing a window, and in the game the left click is shooting, or casting a spell. Then if I want to close the window, my character shoots a fireball and closes the window. How can I solve this problem?
How to check for UI mouse events properly
Started by RobeeZ, Aug 15 2012 07:10 AM
3 replies to this topic
Sponsor:
#4 Members - Reputation: 553
Posted 15 August 2012 - 10:24 AM
In the past, I've written game logic to include several screens. You can think of each screen as a layer of updates with the bottom layer being the game level/logic. Input is filtered from the top screen down to the bottom. On input, the screen can choose to handle it accordingly, and/or pass the input along to the one underneath it.
This makes it easy to pop up a 'pause screen' and halt updates to the 'game screen'. Or in your case, create a 'UI screen' and if input was handled, don't pass it down to the 'game screen' - just like Faelenor suggested.
This makes it easy to pop up a 'pause screen' and halt updates to the 'game screen'. Or in your case, create a 'UI screen' and if input was handled, don't pass it down to the 'game screen' - just like Faelenor suggested.






