Jump to content
  • Advertisement
Sign in to follow this  
Upinflames

GUI

This topic is 3473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, As a test on controls I wish to write a sprite that renders on screen and can be clicked on. I just have no idea how I would add the click event handler to a sprite. Any incite would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
which graphic library do you use?
You might add the click event handler to the canvas widget and then search for if the point you clicked on is on a sprite that is drawn by the canvas widget.

Share this post


Link to post
Share on other sites
I'm just not sure how I would execute it. I have my sprite which I render on screen. But I'm not sure where I should check for the mouse position. In the main msg loop for the window or in a custom one. I also don't know how to get the mouseposition without DI.(I don't want to rely on DI for mouse input yet.

Share this post


Link to post
Share on other sites
Just check if the mouse position is inside the sprite rectangle. Check GD's article section for collision techniques; http://www.gamedev.net/reference/list.asp?categoryid=199

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!