CleanWater

Jack-Of-All-Trades Freelancer
Regular
Joined
Apr 8, 2017
Messages
1,044
Reaction score
1,129
First Language
Português BR
Primarily Uses
RMMV
So, when I play test the game, the full screen resizes and occupies almost the whole screen (besides the letter-boxed black bars at each side), but when I try to enable full screen in my browser hosted game, it's what happens.

Captura de tela de 2022-09-09 11-15-51.png

As many of you already knows, I'm hosting the game at Itch.io.

Is there any way to fix that? Is this something related to the engine or it's a problem from their side?

Thanks in advance!
 

JohnDoeNews

AFK TTYL
Regular
Joined
Apr 25, 2017
Messages
2,262
Reaction score
1,781
First Language
Dutch
Primarily Uses
RMMV
Press F3 when full screen
 
Last edited:

Nolonar

Regular
Regular
Joined
Feb 18, 2018
Messages
504
Reaction score
728
First Language
French, German
Primarily Uses
RMMZ
Edit:
This is actually the superior answer.

If you don't want the players to be forced to press F3 when they launch the game, you can create a simple plugin that calls the following code:
JavaScript:
Graphics._switchStretchMode();
which is what pressing F3 does.

I'll leave my original (inferior) answer in the spoiler below. Feel free to ignore it.
This is a CSS-related issue. On the web, the game canvas is set to have the same size as your game's resolution. Instead, you want the canvas to fill the entire screen. This can easily be fixed by adding the following code to your game's main CSS file:

CSS:
#gameCanvas, #GameCanvas, #gameVideo, #GameVideo {
    width: 100% !important;
    height: 100% !important;
}

The #gameCanvas and #gameVideo are for MZ, and #GameCanvas and #GameVideo are for MV. The !important part is required because the canvas has dimensions specified in the inline style element (inline style has the highest priority in CSS, and !important has an even higher priority).

In MZ, you can add the above code into the /css/game.css file.
For MV, it's a bit more complex, since MV doesn't have a main CSS file. You can either hijack the /fonts/gamefont.css file (easiest), or if you want a cleaner solution, you can create your own /css/game.css file, but then you'll also need to add the following HTML tag to the /index.html file:
HTML:
<link rel="stylesheet" type="text/css" href="css/game.css">

Alternatively, you can inject the CSS using a plugin. You'll need a plugin anyway, if you want the best-possible solution. The reason is because your game will be stretched (no letterboxing) once you change the canvas' (and video player's) dimensions. To fix this, you'll need a plugin.

Using a plugin, the easiest way to solve this problem would be to do the following:
  1. Retrieve window.innerWidth and window.innerHeight
  2. Retrieve the game canvas' dimensions and compute its aspect ratio.
  3. Using the aspect ratio, determine the factor by which to multiply the canvas' width and height, such that both width and height are equal to or smaller than the window's innerWidth or innerHeight.
  4. Modify the canvas' (and video's) style accordingly (the video's dimensions are equal to the canvas', so there's no need to perform the calculations for both).
  5. (optional) Add an event listener to the window's resize event, so that when the player resizes their browser window, the canvas (and video) adapt to it:
    JavaScript:
    window.addEventListener('resize', function(event) { /* do stuff here */ });
 
Last edited:

CleanWater

Jack-Of-All-Trades Freelancer
Regular
Joined
Apr 8, 2017
Messages
1,044
Reaction score
1,129
First Language
Português BR
Primarily Uses
RMMV
Many thanks @JohnDoeNews and @Nolonar ! :smile:

It was easier than I though. I think I'll leave it as that and add some of the game engine controls to a lesson (I was going to do it anyway for the Debug commands).
 

Latest Threads

Latest Posts

Latest Profile Posts

Partitito's story is supposed to be about defeating poverty while thinking he is a capitalist with socialist ideas. But it's really about stories of redemption and perseverance.
Who would have thought an idea like "I wanna put the character bio in the equip screen" would turn into a bunch of work and fun collaboration @Puppet Knight . Now my Equip/Character screen is the way I want it.
Screenshot 2023-12-03 194313.png
Just one more week of grinding through semester finals and I'll be able to actually work on some games and stuff. Hopefully I'll be able to work on my game document to actually have my ideas somewhere outside of my cranium of madness.
With Day 4 of my advent calendar posted, it's time for y'all to choose what Day 5 will be!

We've seen Strength with our adventurers, so which DnD stat would you like to see in the next NPC: Charisma, Constitution, or Wisdom?
Hello everyone im back haha, so im planning to Restart my RPGMAKER project next year when i get new gear to work, But currently im working in Trading card games, if anyone is interested in this world please visit my website :

From there you will be able yo access to my social network profiles or my Discord server.
Good luck to everyone :)

Forum statistics

Threads
136,728
Messages
1,269,235
Members
180,445
Latest member
RenkoUsami
Top