Fit to Browser Window
v1.00
Description
Designed for browser deployed games, this automatically fits the game screen to the width and height of the client's browser window.
Instructions
Plug and play, though it is up to you to create appropriately sized maps and graphics, and to understand how and why this script should or should not be used.
The creator can specify a maximum size and minimum size for their game; the game will not go beyond these boundaries. Leave blank or 0 and the game will just fill the available space.
When testing this plugin please note that the size of the game's title screen and first map are for a small screen, so you won't initially notice that the plugin is working! As I said it is up to you to tailor your game to the plugin.
Credits
Credit to YanFly for a few lines from the resolution changing script. I have just plugged my own variables into these lines.
Notes
I am not used to releasing my plugins publicly so I apologise if I have broken any unwritten rules in my plugin; I've tried to keep to the standards set in the plugins I've seen.
I want to do a new version eventually which will resize the game when the client resizes their browser window, but I am not sure if this is possible. Currently the player will have to reload the game if they change their window size.
The plugin has no benefit whatsoever to a standalone release.
Plugin
v1.00
Description
Designed for browser deployed games, this automatically fits the game screen to the width and height of the client's browser window.
Instructions
Plug and play, though it is up to you to create appropriately sized maps and graphics, and to understand how and why this script should or should not be used.
The creator can specify a maximum size and minimum size for their game; the game will not go beyond these boundaries. Leave blank or 0 and the game will just fill the available space.
When testing this plugin please note that the size of the game's title screen and first map are for a small screen, so you won't initially notice that the plugin is working! As I said it is up to you to tailor your game to the plugin.
Credits
Credit to YanFly for a few lines from the resolution changing script. I have just plugged my own variables into these lines.
Notes
I am not used to releasing my plugins publicly so I apologise if I have broken any unwritten rules in my plugin; I've tried to keep to the standards set in the plugins I've seen.
I want to do a new version eventually which will resize the game when the client resizes their browser window, but I am not sure if this is possible. Currently the player will have to reload the game if they change their window size.
The plugin has no benefit whatsoever to a standalone release.
Plugin
Code:
//=============================================================================
// FitToBrowser.js
//=============================================================================
/*:
* @plugindesc Fit to Browser v1.00
* @author Afar Build 2 / Credit to YanFly for a couple of lines from ScreenResolution.js
*
* @param Minimum Width
* @desc Makes the game not go below this size. 0 = doesn't matter.
* Default: 640
* @default 640
*
* @param Minimum Height
* @desc Makes the game not go below this size. 0 = doesn't matter.
* Default: 480
* @default 480
*
* @param Maximum Width
* @desc Makes the game not go above this size. 0 = doesn't matter.
* Default: 1024
* @default 1024
*
* @param Maximum Height
* @desc Makes the game not go above this size. 0 = doesn't matter.
* Default: 768
* @default 768
*/
var AmyPond = AmyPond || {};
AmyPond.resolution = AmyPond.resolution || {};
AmyPond.parameters = PluginManager.parameters('FitToBrowser');
AmyPond.minWidth = Number(AmyPond.parameters['Minimum Width'] || 0);
AmyPond.minHeight = Number(AmyPond.parameters['Minimum Height'] || 0);
AmyPond.maxWidth = Number(AmyPond.parameters['Maximum Width'] || 0);
AmyPond.maxHeight = Number(AmyPond.parameters['Maximum Height'] || 0);
AmyPond.resize = function() {
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
if (AmyPond.minWidth != 0) {
if (w < AmyPond.minWidth) {
w = AmyPond.minWidth;
}
}
if (AmyPond.maxWidth != 0) {
if (w > AmyPond.maxWidth) {
w = AmyPond.maxWidth;
}
}
if (AmyPond.minHeight != 0) {
if (h < AmyPond.minHeight) {
h = AmyPond.minHeight;
}
}
if (AmyPond.maxHeight != 0) {
if (h > AmyPond.maxHeight) {
h = AmyPond.maxHeight;
}
}
SceneManager._screenWidth = w;
SceneManager._screenHeight = h;
SceneManager._boxWidth = w;
SceneManager._boxHeight = h;
window.resizeBy(w, h);
};
AmyPond.resize();
//=============================================================================
// End of File
//=============================================================================