mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 17:58:23 +00:00
Moved ScaleManager to its own namespace (Phaser.Scale) and out of DOM
This commit is contained in:
parent
696283686a
commit
cb7b335d7f
15 changed files with 65 additions and 39 deletions
|
@ -20,7 +20,7 @@ var Events = require('./events');
|
|||
var InputManager = require('../input/InputManager');
|
||||
var PluginCache = require('../plugins/PluginCache');
|
||||
var PluginManager = require('../plugins/PluginManager');
|
||||
var ScaleManager = require('../dom/ScaleManager');
|
||||
var ScaleManager = require('../scale/ScaleManager');
|
||||
var SceneManager = require('../scene/SceneManager');
|
||||
var SoundManagerCreator = require('../sound/SoundManagerCreator');
|
||||
var TextureEvents = require('../textures/events');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var CONST = require('./const');
|
||||
var CONST = require('../scale/const');
|
||||
|
||||
var GetScreenOrientation = function (width, height)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ var GetScreenOrientation = function (width, height)
|
|||
// moz / ms-orientation are strings
|
||||
return orientation;
|
||||
}
|
||||
|
||||
|
||||
if (screen)
|
||||
{
|
||||
return (screen.height > screen.width) ? CONST.PORTRAIT : CONST.LANDSCAPE;
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Extend = require('../utils/object/Extend');
|
||||
var ScaleModes = require('./const');
|
||||
|
||||
/**
|
||||
* @namespace Phaser.DOM
|
||||
*/
|
||||
|
@ -18,13 +15,8 @@ var Dom = {
|
|||
GetScreenOrientation: require('./GetScreenOrientation'),
|
||||
ParseXML: require('./ParseXML'),
|
||||
RemoveFromDOM: require('./RemoveFromDOM'),
|
||||
RequestAnimationFrame: require('./RequestAnimationFrame'),
|
||||
ScaleManager: require('./ScaleManager'),
|
||||
|
||||
ScaleModes: ScaleModes
|
||||
RequestAnimationFrame: require('./RequestAnimationFrame')
|
||||
|
||||
};
|
||||
|
||||
Dom = Extend(false, Dom, ScaleModes);
|
||||
|
||||
module.exports = Dom;
|
||||
|
|
|
@ -37,6 +37,7 @@ var Phaser = {
|
|||
Arcade: require('./physics/arcade')
|
||||
},
|
||||
Plugins: require('./plugins'),
|
||||
Scale: require('./scale'),
|
||||
Scene: require('./scene/Scene'),
|
||||
Scenes: require('./scene'),
|
||||
Sound: require('./sound'),
|
||||
|
|
|
@ -85,6 +85,7 @@ var Phaser = {
|
|||
},
|
||||
Plugins: require('./plugins'),
|
||||
Renderer: require('./renderer'),
|
||||
Scale: require('./scale'),
|
||||
Scene: require('./scene/Scene'),
|
||||
Scenes: require('./scene'),
|
||||
Sound: require('./sound'),
|
||||
|
|
|
@ -36,6 +36,7 @@ var Phaser = {
|
|||
Physics: require('./physics'),
|
||||
Plugins: require('./plugins'),
|
||||
Renderer: require('./renderer'),
|
||||
Scale: require('./scale'),
|
||||
Scene: require('./scene/Scene'),
|
||||
Scenes: require('./scene'),
|
||||
Sound: require('./sound'),
|
||||
|
|
|
@ -9,8 +9,8 @@ var Class = require('../utils/Class');
|
|||
var EventEmitter = require('eventemitter3');
|
||||
var Events = require('./events');
|
||||
var GameEvents = require('../core/events');
|
||||
var GetInnerHeight = require('./GetInnerHeight');
|
||||
var GetScreenOrientation = require('./GetScreenOrientation');
|
||||
var GetInnerHeight = require('../dom/GetInnerHeight');
|
||||
var GetScreenOrientation = require('../dom/GetScreenOrientation');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
var Rectangle = require('../geom/rectangle/Rectangle');
|
||||
var Size = require('../structs/Size');
|
||||
|
@ -24,7 +24,7 @@ var Vector2 = require('../math/Vector2');
|
|||
* The game size is the logical size of the game; the display size is the scaled size of the canvas.
|
||||
*
|
||||
* @class ScaleManager
|
||||
* @memberof Phaser.DOM
|
||||
* @memberof Phaser.Scale
|
||||
* @extends Phaser.Events.EventEmitter
|
||||
* @constructor
|
||||
* @since 3.16.0
|
|
@ -5,13 +5,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Phaser ScaleManager constants.
|
||||
* Global consts.
|
||||
*
|
||||
* @name Phaser.DOM.ScaleModes
|
||||
* @enum {integer}
|
||||
* @memberof Phaser
|
||||
* @readonly
|
||||
* @since 3.16.0
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
@ -21,7 +17,8 @@ module.exports = {
|
|||
* again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need
|
||||
* to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working.
|
||||
*
|
||||
* @name Phaser.DOM.NONE
|
||||
* @name Phaser.Scale.NONE
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
NONE: 0,
|
||||
|
@ -29,7 +26,8 @@ module.exports = {
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @name Phaser.DOM.WIDTH_CONTROLS_HEIGHT
|
||||
* @name Phaser.Scale.WIDTH_CONTROLS_HEIGHT
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
WIDTH_CONTROLS_HEIGHT: 1,
|
||||
|
@ -37,7 +35,8 @@ module.exports = {
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @name Phaser.DOM.HEIGHT_CONTROLS_WIDTH
|
||||
* @name Phaser.Scale.HEIGHT_CONTROLS_WIDTH
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
HEIGHT_CONTROLS_WIDTH: 2,
|
||||
|
@ -45,7 +44,8 @@ module.exports = {
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @name Phaser.DOM.FIT
|
||||
* @name Phaser.Scale.FIT
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
FIT: 3,
|
||||
|
@ -53,7 +53,8 @@ module.exports = {
|
|||
/**
|
||||
*
|
||||
*
|
||||
* @name Phaser.DOM.ENVELOP
|
||||
* @name Phaser.Scale.ENVELOP
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
ENVELOP: 4,
|
||||
|
@ -61,7 +62,8 @@ module.exports = {
|
|||
/**
|
||||
* Canvas is resized to fit all available parent space, regardless of aspect ratio.
|
||||
*
|
||||
* @name Phaser.DOM.RESIZE
|
||||
* @name Phaser.Scale.RESIZE
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
RESIZE: 5,
|
||||
|
@ -69,7 +71,8 @@ module.exports = {
|
|||
/**
|
||||
* Canvas is not centered within the parent.
|
||||
*
|
||||
* @name Phaser.DOM.NO_CENTER
|
||||
* @name Phaser.Scale.NO_CENTER
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
NO_CENTER: 0,
|
||||
|
@ -77,7 +80,8 @@ module.exports = {
|
|||
/**
|
||||
* Canvas is centered both horizontally and vertically within the parent.
|
||||
*
|
||||
* @name Phaser.DOM.CENTER_BOTH
|
||||
* @name Phaser.Scale.CENTER_BOTH
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
CENTER_BOTH: 1,
|
||||
|
@ -85,7 +89,8 @@ module.exports = {
|
|||
/**
|
||||
* Canvas is centered horizontally within the parent.
|
||||
*
|
||||
* @name Phaser.DOM.CENTER_HORIZONTALLY
|
||||
* @name Phaser.Scale.CENTER_HORIZONTALLY
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
CENTER_HORIZONTALLY: 2,
|
||||
|
@ -93,7 +98,8 @@ module.exports = {
|
|||
/**
|
||||
* Canvas is centered vertically within the parent.
|
||||
*
|
||||
* @name Phaser.DOM.CENTER_VERTICALLY
|
||||
* @name Phaser.Scale.CENTER_VERTICALLY
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
CENTER_VERTICALLY: 3,
|
||||
|
@ -101,7 +107,8 @@ module.exports = {
|
|||
/**
|
||||
* Browser is in landscape orientation.
|
||||
*
|
||||
* @name Phaser.DOM.LANDSCAPE
|
||||
* @name Phaser.Scale.LANDSCAPE
|
||||
* @enum {string}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
LANDSCAPE: 'landscape-primary',
|
||||
|
@ -109,7 +116,8 @@ module.exports = {
|
|||
/**
|
||||
* Browser is in portrait orientation.
|
||||
*
|
||||
* @name Phaser.DOM.PORTRAIT
|
||||
* @name Phaser.Scale.PORTRAIT
|
||||
* @enum {string}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
PORTRAIT: 'portrait-primary',
|
||||
|
@ -118,7 +126,8 @@ module.exports = {
|
|||
* Calculate the zoom value based on the maximum multiplied game size that will
|
||||
* fit into the parent, or browser window if no parent is set.
|
||||
*
|
||||
* @name Phaser.DOM.MAX_ZOOM
|
||||
* @name Phaser.Scale.MAX_ZOOM
|
||||
* @enum {integer}
|
||||
* @since 3.16.0
|
||||
*/
|
||||
MAX_ZOOM: -1
|
|
@ -7,6 +7,6 @@
|
|||
/**
|
||||
* The Scale Manager Resize Event.
|
||||
*
|
||||
* @event Phaser.DOM.ScaleManager.Events#ENTER_FULLSCREEN
|
||||
* @event Phaser.Scale.ScaleManager.Events#ENTER_FULLSCREEN
|
||||
*/
|
||||
module.exports = 'enterfullscreen';
|
|
@ -7,6 +7,6 @@
|
|||
/**
|
||||
* The Scale Manager Resize Event.
|
||||
*
|
||||
* @event Phaser.DOM.ScaleManager.Events#FULLSCREEN_UNSUPPORTED
|
||||
* @event Phaser.Scale.ScaleManager.Events#FULLSCREEN_UNSUPPORTED
|
||||
*/
|
||||
module.exports = 'fullscreenunsupported';
|
|
@ -7,6 +7,6 @@
|
|||
/**
|
||||
* The Scale Manager Resize Event.
|
||||
*
|
||||
* @event Phaser.DOM.ScaleManager.Events#LEAVE_FULLSCREEN
|
||||
* @event Phaser.Scale.ScaleManager.Events#LEAVE_FULLSCREEN
|
||||
*/
|
||||
module.exports = 'leavefullscreen';
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* The Scale Manager Resize Event.
|
||||
*
|
||||
* @event Phaser.DOM.ScaleManager.Events#ORIENTATION_CHANGE
|
||||
* @event Phaser.Scale.ScaleManager.Events#ORIENTATION_CHANGE
|
||||
*
|
||||
* @param {string} orientation -
|
||||
*/
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* The Scale Manager Resize Event.
|
||||
*
|
||||
* @event Phaser.DOM.ScaleManager.Events#RESIZE
|
||||
* @event Phaser.Scale.ScaleManager.Events#RESIZE
|
||||
*
|
||||
* @param {Phaser.Structs.Size} gameSize -
|
||||
* @param {Phaser.Structs.Size} baseSize -
|
22
src/scale/index.js
Normal file
22
src/scale/index.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var Extend = require('../utils/object/Extend');
|
||||
var CONST = require('./const');
|
||||
|
||||
/**
|
||||
* @namespace Phaser.Scale
|
||||
*/
|
||||
|
||||
var Scale = {
|
||||
|
||||
ScaleManager: require('./ScaleManager')
|
||||
|
||||
};
|
||||
|
||||
Scale = Extend(false, Scale, CONST);
|
||||
|
||||
module.exports = Scale;
|
Loading…
Reference in a new issue