Draw Picture at event location

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
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,115
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
31,355
Reaction score
7,668
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
40
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
40,098
Reaction score
13,704
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
40
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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top