Draw Picture at event location

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
Hello!

I try to draw a picture at an events position with:

Code:
$gameScreen.showPicture(params);
The event doesn't have a fixed position. I tried this:

Code:
$gameScreen.showPicture(80, "picname", 1, $gameMap.event($eventID).x*36, $gameMap.event($eventID).y*36, 100, 100, 255, 0);
But it doesn't work. The closest I could get was multiply the x and y with 24. But the pictures still were not at the exact same position as the events.

Does anyone know the pixel dimensions of the grid in RPG Maker MV?

When I put $gameMap.event($eventID).x in the console I get values like 2, 4, 10 or whatever. It counts the tiles between the outer map line and the event. But how many pixels does each tile have?

Thanks in advance!
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,096
First Language
English
Primarily Uses
RMMV
You want to grab the _realX and _realY properties of the event, that should give you the pixel position.

The closest I could get was multiply the x and y with 24. But the pictures still were not at the exact same position as the events.
Each tile in RPG Maker MV is 48x48, you can find more information about the default dimensions in the help manual that comes with MV.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,363
Reaction score
7,202
First Language
German
Primarily Uses
RMMV
But the pictures still were not at the exact same position as
the tile coordinates simply need to be multiplied with 48 to get the screen coordinates in pixels.
What you're missing here is that "Show Picture" as a command can switch between two different forms of pixel coordinates, and from what you're writing I think you're using the centered form - which needs to handle the numbers in a different math than the origin form.

Please check the event command itself and use its different options including the selection which coordinates to use. With that selection you not only switch the base of the coordinates but also the point in the picture that will be locked to those coordinates.
It's difficult to explain, just try the command with a picture and use the same coordinates to see how the display changes, and then use different coordinates at one setting to see the other effect.
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
You want to grab the _realX and _realY properties of the event, that should give you the pixel position.

Each tile in RPG Maker MV is 48x48, you can find more information about the default dimensions in the help manual that comes with MV.
Unfortunately ._realX and ._realY do return the exact same values as .x and .y in the console aswell as if I replace the respective code sections. It did not correct the picture position.
Did I use it correctly?
Code:
$gameMap.event(ID)._realX

the tile coordinates simply need to be multiplied with 48 to get the screen coordinates in pixels.
What you're missing here is that "Show Picture" as a command can switch between two different forms of pixel coordinates, and from what you're writing I think you're using the centered form - which needs to handle the numbers in a different math than the origin form.
I was assuming that *48 aswell. But the picture showed up way beyond the right side of the event. It didn't matter if I put the picture in center or upper left. It is only 96*96 pixels small, so that shouldn't matter too much.

I wonder why ._realX and .x do return the same values.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,614
Reaction score
13,208
First Language
English
Primarily Uses
RMMV
the tile coordinates simply need to be multiplied with 48 to get the screen coordinates in pixels.
Isn't that only valid if the map is the exact size of the screen?

In an event, you can Change Variables and use Game Data > Character's .... to get the Screen X and Screen Y into variables, then use those variables in the Show Picture command, with the picture origin set to Center.

However, if the event is moving, you'd need to put that in a parallel process if you wanted the picture to keep following the event. If you do that, make sure you add a Wait 1 Frame (or a few frames) so it doesn't cause your game to lag.

Why not just use the picture as the event sprite?
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
39
First Language
German
Primarily Uses
RMMV
It might be screenX() and screenY() and then multiply by the size of each tile (48x48 by default)
Thanks I will test that out.


Why not just use the picture as the event sprite?
What I'm trying to do is offering the player the choice where to move, when stepping on junctions. In the example picture below the code was:
Code:
$gameScreen.showPicture(98, "arrow_right", 1, $gameMap.event($turn_number)._realX*48, $gameMap.event($turn_number)._realY*48, 100, 100, 255, 0);
$gameScreen.showPicture(99, "arrow_down", 1, $gameMap.event($turn_number)._realX*48, $gameMap.event($turn_number)._realY*48, 100, 100, 255, 0);




Edit:
It might be screenX() and screenY() and then multiply by the size of each tile (48x48 by default)
Thanks it works perfectly fine now! Although I didn't need to multiply the value.

 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

In other news, my new computer is now ordered, and I'll have it in my hot little hands by the end of the week! CAN'T WAIT!!!
I've said my cat's names in such a baby-talk manner over the years, Biggs is now Biggoro, Bella is now Bellllyyaah, and somehow.....somehow Tessa is Sessashan
Did a massive ****up in my code that would have caused the game to crash on most computers and almost released an update without noticing it.
I keep thinking today is Thursday.
And I look forward to the next preview thread coming this afternoon.
And then I realise it's not Thursday at all.
And then I get sad :(

Forum statistics

Threads
100,449
Messages
976,083
Members
132,082
Latest member
nwr
Top