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,600
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
1,000
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
7,011
Reaction score
4,840
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
481
Reaction score
1,419
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,600
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
7,011
Reaction score
4,840
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
538
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
1,000
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

1675255888435.png
Been working on new characters and outfits, no bodysuit!
doesnt mean she's not mechanical :kaopride:
Sneak peek on what I'm working on (don't mind the tileset, it's placeholder)

1675253833587.png1675253693243.png1675253707818.png
Going to make my Anniebelle dolls into murderous cowards, when the lights go out they swarm, otherwise they flee and attack from a distance...
annieBelle.png

....just look at those beady little eyes. Terrifying! :kaoswt:

Stream for those who like to watch. :LZSwink:
So I sent my game demo to be entered into a game showcase. They asked if I had a website for my game. So I listed my game page here. I don't know if that will count or not.
mp8LcCp.png

Astarte, redefined.

Forum statistics

Threads
128,404
Messages
1,194,282
Members
168,920
Latest member
Garatishanbe
Top