Jump to content
  • Advertisement
Sign in to follow this  
Tispe

How do I detect if cursor is over a sprite?

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

Advertisement
You may want to supply more details about exactly what you want to do. How are you drawing it? Do you want a pixel perfect detection or a bounding box? Is this in 3D or 2D? Do you want to know if the mouse is over any sprite or over a specific sprite?

Share this post


Link to post
Share on other sites
You could do simple rect collision detection on the mouse cursor or the point of the cursor... IE mouse.y > rect.y && mouse.y < rect.height (which is y + rectangle size) and same with x and width.

Share this post


Link to post
Share on other sites
My Sprites are 2D ontop of a 3D world.

Pixel perfect would be nice, kinda like a ray in 3D, but in 2D. Like a D3DXIntersect, but for 2D. Suggestions?

Doing a rect collision would be an option if no other technique is available, or easily implemented.


for(int i=0;i<(int)Sprites.size();i++)
{
d3dspt->Draw(Sprites.sprite, NULL, &Sprites.center, &Sprites.position, Sprites.Color);
}

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!