How do I get the exact pixel location of a given event in RPG Maker MV?
I know I can look at the x, y coordinates of an event but those just five the tile locations. When an event is moving from one tile to another, those are not accurate. So if I want to draw something on the screen pointing to the center of the sprite for an event, I need to know the exact pixel coordinates of the sprite as opposed to the tile.
Bonus question: what is the difference between things like x, realX, scrolledX that I see as properties of things in RMMV?
Thanks.
How to get exact event sprite pixel location (not just tile location)
● ARCHIVED · READ-ONLY
-
-
there is no direct way unless you count the pixels of a sprite from its frame, or unless you change the engine to use pixel movement.
about the different coordinates: a map can be large than the screen, and if it is the map scrolls in the background.
and additionally you can move the camera off-center
that is where you need the different coordinates as in x on the screen, x on the map, x on a scrolled map and so on. -
The solution is just to set the sprite's coordinate to the character's coordinate in the update method. That way, it will be on the player all along.
Also:
- x: the x position.
- realX: the x position, but without counting the between tiles value (I might be switching both x and realX, don't remember exactly).
- scrolledX: I think it's the first visible tile on the x axis on screen.
-
As MushroomCake28 suggests you can access relevant properties via scripting, e.g. Control Variables > Set > Script:
Code:I.e. get event 5's real x-value (i.e. fractional tile x-coordinate) adjusted relative to the current screen position, add 0.5 (offset from top-left to centre), then multiply by 48 px/tile.($gameMap.event(5).scrolledX() + 0.5) * 48
If you want the coordinate without adjusting for screen position, refer directly to _realX, e.g.
Code:($gameMap.event(5)._realX + 0.5) * 48
To get the y-coordinate, just swap scrolledX() or _realX for scrolledY() or _realY. ^_^ -
there is no direct way unless you count the pixels of a sprite from its frame,
Thanks for the answer. Can you clarify what you mean? How do I count pixels of a sprite from its frame? Or at a more basic level, if an event has an X and Y location of (5, 6) but is in the process of moving down to (5, 7) how do I even know that?
Thanks. -
Heey Hello!
Sorry, I never came to this post to solve problems actually... I'd like to ask a question in relation to this post. This is actually my first activity as a member of the forum so thank you very much for all this amazing site. Years ago I was a lot into rpgmaker 2003 and XP, but I quit for a loooong time though I always wanted to finish what I started. The only thing that I'd like to change from rpgmaker2003 is actually the movement of the character, of all the characters (sorry if my terminology isn't correct 100%, again, I've been out of this business for a looooong time), so they can move pixel by pixel rather than tile by tile. That was something that I really wanted to change but my life brought me through diferent paths and I left this world lost in time, forgotten. I believe it is not hard to do at all using code and I believe that mv is the perfect one to develop anything you wish in this kind of levels that I am talking about (or trying to explain, hope you understand).
Thank you very much! -
@dragonhyle Please do not use someone else's thread to ask your own query. That is hi-jacking.
I suggest you create a new thread , in JS Plugin Requests, and ask for links to pixel movement plugins. -
Okay, thanks. I'll do!