how to get absolute mouse coordinates

Started by selmiak, Fri 17/06/2011 20:15:55

Previous topic - Next topic

selmiak

I want the exact room coordinates where a mouseclick happens and mouse.x for example only gives me the screen coordinates and not the room coordinates. What do I use? GetAtRoomXY doesn't help as it just tell what is there but doesn't give the coordinates.

barefoot

I think checkout

GetViewportX() and GetViewportY()


barefoot
I May Not Be Perfect but I Have A Big Heart ..

selmiak

with (GetViewportX()+mouse.x) it works, thanks barefoot :)

strange that there is no native expression for this...

monkey0506

Well you could write some custom functions pretty easily:

Code: ags
int RoomXToScreenX(int x)
{
  return (x - GetViewportX());
}

int RoomYToScreenY(int y)
{
  return (y - GetViewportY());
}

int ScreenXToRoomX(int x)
{
  return (x + GetViewportX());
}

int ScreenYToRoomY(int y)
{
  return (y + GetViewportY());
}

SMF spam blocked by CleanTalk