Detecting the object on which mouse is over. *SOLVED*

Started by Chim, Wed 13/10/2010 14:06:17

Previous topic - Next topic

Chim

Hello AGS community,

I would to know if there is a simple function in AGS which would return the object on which mouse is over, be it a Hotspot, a character, an object or nothing at all.

Otherwise, It would be possible to do it by checking the current mouse position and the position of every object in room... but well, that would be less neat.

Thank you very much !

Khris

I usually do it like this:

Code: ags
  int mx = mouse.x, my = mouse.y;
  int lt = GetLocationType(mx, my);

  // object?
  Object*o;
  if (lt == eLocationObject) {
    o = Object.GetAtScreenXY(mx, my);
    ...
  }

  // etc.


There are also GetAtScreenXY functions for InventoryItems, Characters, Hotspots. For regions, there's GetAtRoomXY().

If you just need the name, there's
  String s = Game.GetLocationName(mouse.x, mouse.y);
  CursorLabel.Text = s;  // put name on text following the mouse

Chim

Thanks a lot, that's exactly what I was looking for.

I had not found yet the eLocationType to compare to !

SMF spam blocked by CleanTalk