Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to check for UI mouse events properly


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 RobeeZ   Members   -  Reputation: 206

Like
0Likes
Like

Posted 15 August 2012 - 07:10 AM

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?

Sponsor:

#2 Faelenor   Members   -  Reputation: 396

Like
3Likes
Like

Posted 15 August 2012 - 08:25 AM

Send your mouse event to the UI first and make the UI return a true/false value if it handled the event or not. If not, send the event to the game code.

#3 RobeeZ   Members   -  Reputation: 206

Like
0Likes
Like

Posted 15 August 2012 - 08:43 AM

Really good idea. I'll look into it :) Thanks for help

#4 web383   Members   -  Reputation: 758

Like
2Likes
Like

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS