Joined
Dec 16, 2012
Messages
128
Reaction score
8
First Language
English
Primarily Uses
I have an image I need to display in the dead center of the screen. I'm using "Show Picture" but I need it to draw in the center of the screen. I could just use the "Direct Designation" and aim for the middle, but I want to make sure it's in the center for all resolutions. I've tried using the "Center" option from the dropdown, but the picture fails to appear at all when doing that.

Question: Is there a way to store the game's X and Y resolutions to be used as a variable? That way I could simply (X_resolution/2)+(Y_resolution+2) = coordinates to draw image.

Any assistance would be greatly appreciated. Thanks!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,782
Reaction score
5,597
First Language
English
Primarily Uses
RMMZ
You haven't specified which maker this is for. However, using the "center" option, 0,0 should be dead centre of the screen no matter the resolution.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
998
Reaction score
485
First Language
PT-BR
Primarily Uses
RM2k3
Hello, try this:
Graphics._width and Graphics._height

Example (MV/MZ):
JavaScript:
$gameScreen.showPicture(1,'MyPic',1,Graphics._width/2,Graphics._height/2,100,100,255,0);
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,982
Reaction score
4,821
First Language
English
Primarily Uses
RMMV
..."center"...centre
I don't have anything to say, this just amused me :smile:

I've tried using the "Center" option from the dropdown, but the picture fails to appear at all when doing that.
I would suggest before/rather than resorting to script calls, you figure this out. It implies to me that something is wrong with your picture that calling the same function in a different way won't resolve.

Is your image of a resolution that fits within your game window? Does the canvas size match the image dimensions?
 

BK-tdm

Manga Maker
Veteran
Joined
Jun 21, 2018
Messages
478
Reaction score
1,414
First Language
English
Primarily Uses
RMMV
The lazy solution: check your game resolution (lets say 1280x720) make that exact same resolution transparent image on an image editor, add your desired image, center it as you want, save in pictures folder and use display picture with default settings, the image will be centered whitout any need for variables/tweaks.
Since this is directly tied to the game native resolution, fullscreening or altering the game window size will adjust the image accordingly.
 
Joined
Dec 16, 2012
Messages
128
Reaction score
8
First Language
English
Primarily Uses
I don't have anything to say, this just amused me :smile:


I would suggest before/rather than resorting to script calls, you figure this out. It implies to me that something is wrong with your picture that calling the same function in a different way won't resolve.

Is your image of a resolution that fits within your game window? Does the canvas size match the image dimensions?
It's super weird. I tell it to display in the upper left, and it draws the picture without issue. But if I tell it to draw to the center, it doesn't appear at all. It's literally the only thing I'm changing (upper-left vs center). I don't know what else would be making it not appear. There's nothing in the room other than the Player Character and the Room GM to handle the script. It's a major head scratcher.

The lazy solution: check your game resolution (lets say 1280x720) make that exact same resolution transparent image on an image editor, add your desired image, center it as you want, save in pictures folder and use display picture with default settings, the image will be centered whitout any need for variables/tweaks.
Since this is directly tied to the game native resolution, fullscreening or altering the game window size will adjust the image accordingly.
That's a pretty smart way to handle it! Thanks! If I can't figure out why the picture stops appearing when I select "center" then I'll likely use this solution. Much obliged!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,782
Reaction score
5,597
First Language
English
Primarily Uses
RMMZ
I don't have anything to say, this just amused me :smile:


I would suggest before/rather than resorting to script calls, you figure this out. It implies to me that something is wrong with your picture that calling the same function in a different way won't resolve.

Is your image of a resolution that fits within your game window? Does the canvas size match the image dimensions?
I said center in the quote because that's literally what the option is called in the dropdown, and centre outside of that because that's how I spell it where I'm from. :p
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,982
Reaction score
4,821
First Language
English
Primarily Uses
RMMV
@Trihan I understand exactly why you typed that way! As I said, no criticism, just amusement :smile:
 

TheAM-Dol

Randomly Generated User Name
Veteran
Joined
Feb 26, 2022
Messages
424
Reaction score
536
First Language
English
Primarily Uses
RMMV
But if I tell it to draw to the center, it doesn't appear at all.
That's because you're not telling it where to draw the image, you're telling the software where the origin is for all the other parameters to effect it. So for example, with a top left origin, using the scale image options to scale up the image will scale the image diagonally right and downward. From the center, the image will scale outward in all directions.
These origin points are based on the image file, so either top left of the associated image or center of the associated image.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
998
Reaction score
485
First Language
PT-BR
Primarily Uses
RM2k3
What I explained was accordingly. Sorry if I misunderstood:
but I want to make sure it's in the center for all resolutions

About working with images with a transparent background, maybe some API can read the image and consider only the non-transparent parts. But I think this is unnecessary.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
10,078
Reaction score
6,380
First Language
Dutch
Primarily Uses
RMXP
I'm going to assume you're using MZ.

I've moved this thread to MZ Support. Thank you.

 

Latest Threads

Latest Posts

Latest Profile Posts

So I managed to scare my chief. Between shifts I had an appointment with my psychiatrist, so prior to it I'd told him "If I ain't coming today, they've kept me there.". Then as I was asleep, my phone died. So I overslept and through the entire time I was unreachable.
I spent so much time toiling in VX Ace frankensteining scripts together only for MV to come along and just... have everything.

The overworld tool system in particular I thought was gonna take me a million years to recreate, but nope. Thanks Moghunter.
Going to go live way earlier than usual tonight, pretty much in 20 minutes, purely because I'm bored. :LZSlol:

So... I'm gonna be a parent... XD

Forum statistics

Threads
128,380
Messages
1,194,070
Members
168,879
Latest member
ultragore
Top