[SOLVED] Hotspot GetAtScreenXY in a scrolling room not working properly

Started by Egmundo Huevoz, Mon 15/01/2018 16:49:59

Previous topic - Next topic

Egmundo Huevoz

I'm making a map room, which is pretty big, and therefore scrolling.
I have this line of code, which I use to get what hotspot the character is currently standing, and then do something else with this information.
Code: ags
Hotspot *player_hotspot = Hotspot.GetAtScreenXY(player.x,player.y);

But it doesn't work properly; the hotspots are circles and the game only knows the player is standing in a hotspot in certain areas of this circle, but not in most of it (I know this because I have a label showing me a variable that changes whether or not the player is standing in a hotspot). I know it's the scrolling room's fault because I imported the room code into another room, put a smaller background so the room isn't a scrolling room, and it works perfectly. I've tried with GetViewport, but that only makes matters worse.

Any insight will be greatly appreciated.

dayowlron

player's x and y are room coordinates and GetAtScreenXY wants screen coordinates.
You need to adjust the players coordinates within the call.
I believe you need to subtract the ViewPortX and ViewPortY from the coordinates to get the correct screen coordinates.

Code: ags

Hotspot *player_hotspot = Hotspot.GetAtScreenXY(player.x-GetViewportX(),player.y-GetViewportY());
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Egmundo Huevoz

Incredible... I mean, I've been programming this game for the past 14 hours, but still, I can't believe I missed that (laugh) I was ADDING instead of SUBSTRACTING.

Thanks a lot, now I can go to sleep in peace.

SMF spam blocked by CleanTalk