How do I find the player's coordinates relative to the screen?

Started by Danvzare, Thu 13/12/2018 18:23:23

Previous topic - Next topic

Danvzare


I think my subject line says it all, but I'll try to explain further.


I want to use:
Code: ags
Room.ProcessClick(player.x, player.y, eModeInteract);

But I can't, because player.x and player.y returns the position of the player relative to the room, and Room.ProcessClick wants an x and y value relative to the screen. This in turns causes a lot of problems for scrolling rooms.
I'm sure the answer is a simple formula of some kind involving the viewport and room width or something, but I can't for the life of me figure it out.

Slasher


Scrolling rooms use;
Code: ags

Room.ProcessClick(player.x + GetViewportX(), player.y+ GetViewportY());



Danvzare


Changing it to:
Code: ags

Room.ProcessClick(player.x - GetViewportX(), player.y - GetViewportY());


Makes it work perfectly. Thank you so very much Slasher.  :D
And sorry for being so very VERY dumb.

SMF spam blocked by CleanTalk