Sign in to follow this  
Upinflames

GUI

Recommended Posts

Upinflames    122
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
AnusCancer    122
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
Upinflames    122
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
HomerSp    126
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this