Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: (Solved) Player screen X and Y giving wrong numbers when zoomed in
- Original author: chris-cote
- Original date: July 24, 2024
- Source thread: https://forums.rpgmakerweb.com/threads/solved-player-screen-x-and-y-giving-wrong-numbers-when-zoomed-in.170579/
- Source forum path: Game Development Engines > RPG Maker MZ Support
Summary
SOLUTION: If you are using a map zoom plugin like MultiTweaks or Arthran's port of the Zoom function of it and have this same issue, here is the solution: Instead of just using the screenX and screenY, you need to use: If screen is 1248x720, tile size is 16 and zoom ratio is x3:
Archived First Post
SOLUTION:
If you are using a map zoom plugin like MultiTweaks or Arthran's port of the Zoom function of it and have this same issue, here is the solution:
Instead of just using the screenX and screenY, you need to use:
If screen is 1248x720, tile size is 16 and zoom ratio is x3:
$gamePlayer.screenX() is actually: (($gamePlayer.screenX() - 624) / (16/3) * 16) + 624
$gamePlayer.screenY() is actually: (($gamePlayer.screenY() - 360) / (16/3) * 16) + 360
If using any other zoom ratio or screen res, update values accordingly:
(($gamePlayer.screenX() - (screenHeight/2)) / (tileSize/zoomFactor) * tileSize) + (screenHeight/2)
(($gamePlayer.screenY() - (screenWidth/2)) / (tileSize/zoomFactor) * tileSize) + (screenWidth/2)
The game registers the center coordinates (half screen size X and Y) correctly, but only moves left/right/up/down each tile by your tile size / your zoom ratio, rather than your full tile size. This math calculates the missing amount and adds it, resolving the problem keeping the X and Y relative to your actual player location on screen.
==================================================
Hey folks,
I am trying to get the player's coordinates on the screen so that I can render some images relative to the player sprite even when they are not centered on screen. I figured that $gamePlayer.screenX() and $gamePlayer.screenY() would give my exact position on the screen, however this doesn't seem to be working with the map zoom set to 3x using MultiTweaks (or any other means of zooming in that I have tested).
In this screenshot, the NPC I am talking to shows text with those 2 variables (screen X and Y), but the numbers don't make sense. When I render something using those variables, it is still generally around the center of the screen even when I am down in the corner like in the pic.
Example:
The screen is 1248x720, so this coordinate doesn't make sense. It does look about right when I am centered, and it changes as I move out of center, but not to my actual position on the screen.
If I turn off my zoom plugin, things work properly:
Any idea what could be going on here?
Thanks!
Update:
Here is a demo project showcasing the issue:
DOWNLOAD
If you are using a map zoom plugin like MultiTweaks or Arthran's port of the Zoom function of it and have this same issue, here is the solution:
Instead of just using the screenX and screenY, you need to use:
If screen is 1248x720, tile size is 16 and zoom ratio is x3:
$gamePlayer.screenX() is actually: (($gamePlayer.screenX() - 624) / (16/3) * 16) + 624
$gamePlayer.screenY() is actually: (($gamePlayer.screenY() - 360) / (16/3) * 16) + 360
If using any other zoom ratio or screen res, update values accordingly:
(($gamePlayer.screenX() - (screenHeight/2)) / (tileSize/zoomFactor) * tileSize) + (screenHeight/2)
(($gamePlayer.screenY() - (screenWidth/2)) / (tileSize/zoomFactor) * tileSize) + (screenWidth/2)
The game registers the center coordinates (half screen size X and Y) correctly, but only moves left/right/up/down each tile by your tile size / your zoom ratio, rather than your full tile size. This math calculates the missing amount and adds it, resolving the problem keeping the X and Y relative to your actual player location on screen.
==================================================
Hey folks,
I am trying to get the player's coordinates on the screen so that I can render some images relative to the player sprite even when they are not centered on screen. I figured that $gamePlayer.screenX() and $gamePlayer.screenY() would give my exact position on the screen, however this doesn't seem to be working with the map zoom set to 3x using MultiTweaks (or any other means of zooming in that I have tested).
In this screenshot, the NPC I am talking to shows text with those 2 variables (screen X and Y), but the numbers don't make sense. When I render something using those variables, it is still generally around the center of the screen even when I am down in the corner like in the pic.
Example:
The screen is 1248x720, so this coordinate doesn't make sense. It does look about right when I am centered, and it changes as I move out of center, but not to my actual position on the screen.
If I turn off my zoom plugin, things work properly:
Any idea what could be going on here?
Thanks!
Update:
Here is a demo project showcasing the issue:
DOWNLOAD
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...