Sign in to follow this  

Clickable custom-shaped area

This topic is 2484 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

Hi
How do i set up a custom (polygon) area like in risk where you have regions and they are clickable?
Would i set up a series of points and see if mouse-cursor is "within" these or how do i go about this task?

Thanks a lot
Erik

Share this post


Link to post
Share on other sites
Try this [url="http://en.wikipedia.org/wiki/Point_in_polygon"]Point in Polygon[/url]. Just test if your moues pointer is in a polygon. Implementing it is pretty strait forward and there are also some implementations floating around the Internet.

Share this post


Link to post
Share on other sites
(Assuming Windows API)
Rather than a polygon, you can use a "region". A region is any arbitrary size and shape, not just a polygon. You can load art and convert it to a region, or you can add and subtract shapes from a region. Then test if the point is within the region.

A Google search for [url="https://encrypted.google.com/search?hl=en&q=region+from+bitmap"]region from bitmap[/url] gives a bunch of results about creating the region and using it for hit detection and other purposes.

Share this post


Link to post
Share on other sites

This topic is 2484 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.

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