Jump to content

  • Log In with Google      Sign In   
  • Create Account

Best way to see if mouse clicked in a certain area


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
1 reply to this topic

#1 noatom   Members   -  Reputation: 469

Like
0Likes
Like

Posted 20 October 2012 - 10:11 AM

I'm taling about 2D not 3D!

So if I have a quad that has a width of 200 and a height of 100.

What is the easiest way to check if a click is done inside of it?
I tried using rect structures,but the coords of the rect structure must use win32 coord system.

D3D uses a cartesian coord system...totally different from win32.

So,how does one find out where a click has taken place in D3D?

Edited by noatom, 20 October 2012 - 11:10 AM.

Like a sir

Sponsor:

#2 Budinga   Members   -  Reputation: 178

Like
0Likes
Like

Posted 20 October 2012 - 02:15 PM

The simplest way to do it is to just check the mounse has clicked within the bounds of the rectangle.

example: This is just a psudo example.


if (mouse.leftclick)
{

if (mouse.x > rectangle.position.x && mouse.x < (rectangle.position.x+width))
{
	 if (mouse.y < rectangle.position.y && mouse.y < (rectangle.position.y + height))
	 {
		   do something when rectangle is cliked.		
	 }
}

}

 

If you mean what i think you mean about win32 to d3d you mean you need to compensate for the clientsize verses windows size have a look at this link.

[url="http://www.directxtutorial.com/Tutorial11/A-A/AA4.aspx"]http://www.directxtutorial.com/Tutorial11/A-A/AA4.aspx[/url]

Edited by Budinga, 20 October 2012 - 02:21 PM.





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