0

First of all we are in XNA/Monogame :)

Hey guys, I have classes like DebugWindow, GameObject, Player(Child from GO),DebugItemSlot

and my question is how to get the position of the gameobject that I just clicked? I already got a click Event so I just need to get the data from the GO I just clicked. Because later on I want to Edit things with my DebugWindow. Hope you understand me and we can come together. If you wish I can add code later that's not the problem.

Juri.B
  • 28
  • 2
  • 9
  • Your GameObjects should contain a Vector2D position. If your window receives a click you check for a "collision". E.g your GameObject contains a rectangle property. After a click you retrieve the current mouse position and check if they intersect. new Rectangle(Mouse.X, Mouse.Y, 2, 2).Intersects(GO.Rectangle); If the result is true, you know which GO is overlapping the cursor. – Bin4ry Nov 30 '16 at 12:47
  • Yeah I have a Rectangle that's called bounds already and I'm already checking if i clicked an Object but how can I know which Object it is and how to pass the data to my DebugWindow class? Code examples would be good – Juri.B Nov 30 '16 at 17:37

0 Answers0