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 !
I usually do it like this:
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
Thanks a lot, that's exactly what I was looking for.
I had not found yet the eLocationType to compare to !