Aspect Ratio and Orientation
A browser window can have any shape, and a phone can be held either way. Three settings in js/options.js decide what your game does about it.
| Setting | Default | Starter game |
|---|---|---|
ForceAspectRatio |
'None' |
same |
AspectRatio |
'16:9' |
same |
Orientation |
'any' |
'landscape' |
All three are read when the game starts, so reload the page after changing them.
Keep the game in one shape
With ForceAspectRatio at 'None', the game fills the window and the scene covers it, so part of the scene may be cut off. The other two values keep part or all of the game in the shape of AspectRatio, as large as the window allows and centered, and follow the window when it’s resized:
monogatari.settings({
'AspectRatio': '16:9',
'ForceAspectRatio': 'Global',
});ForceAspectRatio |
What keeps the shape |
|---|---|
'None' |
Nothing. The game fills the window. |
'Visuals' |
The scene, the characters and the images. The text box and the quick menu still span the whole window, and the space on each side of the scene is black. |
'Global' |
The whole game, menus included. The space around it shows the page’s background. |
The same game in a window wider than 16:9 (1200 × 500), with each value:



AspectRatio is the width and height of your scenes, separated by a colon: '16:9', '4:3', '21:9'. It’s only used when ForceAspectRatio isn’t 'None'.
Ask players to turn their device
On a phone or tablet held the other way, a game drawn for a wide screen is hard to play. Set Orientation to the way your game should be held, and players holding it the other way see a message over the game asking them to turn their device:
monogatari.settings({
'Orientation': 'landscape',
});
Orientation |
Effect |
|---|---|
'any' |
No message. |
'landscape' |
The message appears on phones and tablets held upright. |
'portrait' |
The message appears on phones and tablets held sideways. |
The message goes away when the player turns the device. Its OK button closes it too, so a player whose screen rotation is locked, or who prefers to, can keep playing the other way; turning the device the wrong way again brings it back. The starter game sets 'landscape', so while you try it on a phone held upright, you see this message: turn the phone, press OK, or set 'any'. The message is in the player’s language, and it only appears on phones and tablets; a desktop browser never shows it, whatever the window’s shape.
Before 2.9.0 the message had no button, so a player holding the device upright couldn’t play at all.
If your game is drawn upright, also change "orientation": "landscape" to "portrait" in the starter game’s manifest.json, the file browsers read when a player installs the game to their home screen.
Desktop builds
In a desktop build made with Electron or Electrobun, ForceAspectRatio at 'Global' also fixes the window’s shape: the player picks a size from the settings screen’s Resolution list, and in the Electron app can’t resize the window by dragging (Electrobun has no way to lock a window’s size). See Window size in desktop builds.
Related pages
- Game Settings: every setting.
- Player Preferences: the
Resolutionpreference of desktop builds. - Style and Design: changing how the game looks on different screens.