Texture2D.Bounds.Intersect, but the Bounds never move? - XNA, .Net 4.0

Posted by Gineer on Stack Overflow See other posts from Stack Overflow or by Gineer
Published on 2010-04-21T07:24:14Z Indexed on 2010/04/21 8:03 UTC
Read the original article Hit count: 240

Hi all, I am still shiny new to XNA, so please forgive any stupid question and statements in this post (The added issue is that I am using Visual Studio 2010 with .Net 4.0 which also means very few examples exist out on the web - well, none that I could find easily):

I have two 2D objects in a "game" that I am using to learn more about XNA. I need to figure out when these two objects intersect.

I noticed that the Texture2D objects has a property named "Bounds" which in turn has a method named "Intersects" which takes a Rectangle (the other Texture2D.Bounds) as an argument.

However when you run the code, the objects always intersect even if they are on separate sides of the screen. When I step into the code, I noticed that for the Texture2D Bounds I get 4 parameters back when you mouse over the Bounds and the X, and Y coordinates always read "X = 0, Y = 0" for both objects (hence they always intersect).

The thing that confuses me is the fact that the Bounds property is on the Texture rather than on the Position (or Vector2) of the objects. I eventually created a little helper method that takes in the objects and there positions and then calculate whether they intersect, but I'm sure there must be a better way.

any suggestions, pointers would be much appreciated.

Gineer

© Stack Overflow or respective owner

Related posts about XNA

Related posts about visual-studio-2010