mirror of
https://github.com/wassname/phaser.git
synced 2026-07-14 01:10:16 +08:00
Adding docs.
This commit is contained in:
+29
-31
@@ -1,28 +1,26 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Canvas
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
|
||||
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
|
||||
*
|
||||
* @class Canvas
|
||||
* @static
|
||||
*/
|
||||
|
||||
Phaser.Canvas = {
|
||||
/**
|
||||
* Creates the <canvas> tag
|
||||
* Creates the <canvas> tag
|
||||
*
|
||||
* @method create
|
||||
* @param {number} width The desired width
|
||||
* @param {number} height The desired height
|
||||
* @return {HTMLCanvasElement} the newly created <canvas> tag
|
||||
* @param {number} width - The desired width.
|
||||
* @param {number} height - The desired height.
|
||||
* @return {HTMLCanvasElement} The newly created <canvas> tag.
|
||||
*/
|
||||
create: function (width, height) {
|
||||
|
||||
width = width || 256;
|
||||
height = height || 256;
|
||||
|
||||
@@ -38,9 +36,9 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Get the DOM offset values of any given element
|
||||
* @method getOffset
|
||||
* @param {HTMLElement} element The targeted element that we want to retrieve the offset
|
||||
* @param {Phaser.Point} [point] The point we want to take the x/y values of the offset
|
||||
* @return point {Phaser.Point} A point objet with the offsetX and Y as its properties
|
||||
* @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
|
||||
* @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
|
||||
* @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
|
||||
*/
|
||||
getOffset: function (element, point) {
|
||||
|
||||
@@ -63,8 +61,8 @@ Phaser.Canvas = {
|
||||
* Returns the aspect ratio of the given canvas.
|
||||
*
|
||||
* @method getAspectRatio
|
||||
* @param {HTMLCanvasElement} canvas The canvas to get the aspect ratio from.
|
||||
* @return {Number} Returns true on success
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
|
||||
* @return {number} The ratio between canvas' width and height.
|
||||
*/
|
||||
getAspectRatio: function (canvas) {
|
||||
return canvas.width / canvas.height;
|
||||
@@ -74,8 +72,8 @@ Phaser.Canvas = {
|
||||
* Sets the background color behind the canvas. This changes the canvas style property.
|
||||
*
|
||||
* @method setBackgroundColor
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the background color on.
|
||||
* @param {String} color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the background color on.
|
||||
* @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setBackgroundColor: function (canvas, color) {
|
||||
@@ -92,9 +90,9 @@ Phaser.Canvas = {
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*
|
||||
* @method setTouchAction
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
|
||||
* @param {String} value The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {String} [value] - The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} The source canvas.
|
||||
*/
|
||||
setTouchAction: function (canvas, value) {
|
||||
|
||||
@@ -127,9 +125,9 @@ Phaser.Canvas = {
|
||||
* If no parent is given it will be added as a child of the document.body.
|
||||
*
|
||||
* @method addToDOM
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
|
||||
* @param {String} parent The DOM element to add the canvas to. Defaults to ''.
|
||||
* @param {bool} overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {string} parent - The DOM element to add the canvas to. Defaults to ''.
|
||||
* @param {bool} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
addToDOM: function (canvas, parent, overflowHidden) {
|
||||
@@ -167,13 +165,13 @@ Phaser.Canvas = {
|
||||
* Sets the transform of the given canvas to the matrix values provided.
|
||||
*
|
||||
* @method setTransform
|
||||
* @param {CanvasRenderingContext2D} context The context to set the transform on.
|
||||
* @param {Number} translateX The value to translate horizontally by.
|
||||
* @param {Number} translateY The value to translate vertically by.
|
||||
* @param {Number} scaleX The value to scale horizontally by.
|
||||
* @param {Number} scaleY The value to scale vertically by.
|
||||
* @param {Number} skewX The value to skew horizontaly by.
|
||||
* @param {Number} skewY The value to skew vertically by.
|
||||
* @param {CanvasRenderingContext2D} context - The context to set the transform on.
|
||||
* @param {number} translateX - The value to translate horizontally by.
|
||||
* @param {number} translateY - The value to translate vertically by.
|
||||
* @param {number} scaleX - The value to scale horizontally by.
|
||||
* @param {number} scaleY - The value to scale vertically by.
|
||||
* @param {number} skewX - The value to skew horizontaly by.
|
||||
* @param {number} skewY - The value to skew vertically by.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
|
||||
@@ -192,8 +190,8 @@ Phaser.Canvas = {
|
||||
* patchy on earlier browsers, especially on mobile.
|
||||
*
|
||||
* @method setSmoothingEnabled
|
||||
* @param {CanvasRenderingContext2D} context The context to enable or disable the image smoothing on.
|
||||
* @param {bool} value If set to true it will enable image smoothing, false will disable it.
|
||||
* @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
|
||||
* @param {bool} value - If set to true it will enable image smoothing, false will disable it.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setSmoothingEnabled: function (context, value) {
|
||||
@@ -213,7 +211,7 @@ Phaser.Canvas = {
|
||||
* Note that if this doesn't given the desired result then see the setSmoothingEnabled.
|
||||
*
|
||||
* @method setImageRenderingCrisp
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set image-rendering crisp on.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setImageRenderingCrisp: function (canvas) {
|
||||
|
||||
+112
-84
@@ -1,184 +1,194 @@
|
||||
/**
|
||||
* Phaser - Device
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Device
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
|
||||
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js
|
||||
* {@link https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js}
|
||||
*
|
||||
* @class Phaser.Device
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
Phaser.Device = function () {
|
||||
|
||||
/**
|
||||
* An optional 'fix' for the horrendous Android stock browser bug
|
||||
* https://code.google.com/p/android/issues/detail?id=39247
|
||||
* @type {boolean}
|
||||
* {@link https://code.google.com/p/android/issues/detail?id=39247}
|
||||
* @property {bool} patchAndroidClearRectBug - Description.
|
||||
* @default
|
||||
*/
|
||||
this.patchAndroidClearRectBug = false;
|
||||
|
||||
// Operating System
|
||||
|
||||
/**
|
||||
* Is running desktop?
|
||||
* @type {boolean}
|
||||
* @property {bool} desktop - Is running desktop?
|
||||
* @default
|
||||
*/
|
||||
this.desktop = false;
|
||||
|
||||
/**
|
||||
* Is running on iOS?
|
||||
* @type {boolean}
|
||||
* @property {bool} iOS - Is running on iOS?
|
||||
* @default
|
||||
*/
|
||||
this.iOS = false;
|
||||
|
||||
/**
|
||||
* Is running on android?
|
||||
* @type {boolean}
|
||||
* @property {bool} android - Is running on android?
|
||||
* @default
|
||||
*/
|
||||
this.android = false;
|
||||
|
||||
/**
|
||||
* Is running on chromeOS?
|
||||
* @type {boolean}
|
||||
* @property {bool} chromeOS - Is running on chromeOS?
|
||||
* @default
|
||||
*/
|
||||
this.chromeOS = false;
|
||||
|
||||
/**
|
||||
* Is running on linux?
|
||||
* @type {boolean}
|
||||
* @property {bool} linux - Is running on linux?
|
||||
* @default
|
||||
*/
|
||||
this.linux = false;
|
||||
|
||||
/**
|
||||
* Is running on maxOS?
|
||||
* @type {boolean}
|
||||
* @property {bool} maxOS - Is running on maxOS?
|
||||
* @default
|
||||
*/
|
||||
this.macOS = false;
|
||||
|
||||
/**
|
||||
* Is running on windows?
|
||||
* @type {boolean}
|
||||
* @property {bool} windows - Is running on windows?
|
||||
* @default
|
||||
*/
|
||||
this.windows = false;
|
||||
|
||||
// Features
|
||||
|
||||
/**
|
||||
* Is canvas available?
|
||||
* @type {boolean}
|
||||
* @property {bool} canvas - Is canvas available?
|
||||
* @default
|
||||
*/
|
||||
this.canvas = false;
|
||||
|
||||
/**
|
||||
* Is file available?
|
||||
* @type {boolean}
|
||||
* @property {bool} file - Is file available?
|
||||
* @default
|
||||
*/
|
||||
this.file = false;
|
||||
|
||||
/**
|
||||
* Is fileSystem available?
|
||||
* @type {boolean}
|
||||
* @property {bool} fileSystem - Is fileSystem available?
|
||||
* @default
|
||||
*/
|
||||
this.fileSystem = false;
|
||||
|
||||
/**
|
||||
* Is localStorage available?
|
||||
* @type {boolean}
|
||||
* @property {bool} localStorage - Is localStorage available?
|
||||
* @default
|
||||
*/
|
||||
this.localStorage = false;
|
||||
|
||||
/**
|
||||
* Is webGL available?
|
||||
* @type {boolean}
|
||||
* @property {bool} webGL - Is webGL available?
|
||||
* @default
|
||||
*/
|
||||
this.webGL = false;
|
||||
|
||||
/**
|
||||
* Is worker available?
|
||||
* @type {boolean}
|
||||
* @property {bool} worker - Is worker available?
|
||||
* @default
|
||||
*/
|
||||
this.worker = false;
|
||||
|
||||
/**
|
||||
* Is touch available?
|
||||
* @type {boolean}
|
||||
* @property {bool} touch - Is touch available?
|
||||
* @default
|
||||
*/
|
||||
this.touch = false;
|
||||
|
||||
/**
|
||||
* Is mspointer available?
|
||||
* @type {boolean}
|
||||
* @property {bool} mspointer - Is mspointer available?
|
||||
* @default
|
||||
*/
|
||||
this.mspointer = false;
|
||||
|
||||
/**
|
||||
* Is css3D available?
|
||||
* @type {boolean}
|
||||
* @property {bool} css3D - Is css3D available?
|
||||
* @default
|
||||
*/
|
||||
this.css3D = false;
|
||||
|
||||
/**
|
||||
* Is Pointer Lock available?
|
||||
* @type {boolean}
|
||||
/**
|
||||
* @property {bool} pointerLock - Is Pointer Lock available?
|
||||
* @default
|
||||
*/
|
||||
this.pointerLock = false;
|
||||
|
||||
// Browser
|
||||
|
||||
/**
|
||||
* Is running in arora?
|
||||
* @type {boolean}
|
||||
* @property {bool} arora - Is running in arora?
|
||||
* @default
|
||||
*/
|
||||
this.arora = false;
|
||||
|
||||
/**
|
||||
* Is running in chrome?
|
||||
* @type {boolean}
|
||||
* @property {bool} chrome - Is running in chrome?
|
||||
* @default
|
||||
*/
|
||||
this.chrome = false;
|
||||
|
||||
/**
|
||||
* Is running in epiphany?
|
||||
* @type {boolean}
|
||||
* @property {bool} epiphany - Is running in epiphany?
|
||||
* @default
|
||||
*/
|
||||
this.epiphany = false;
|
||||
|
||||
/**
|
||||
* Is running in firefox?
|
||||
* @type {boolean}
|
||||
* @property {bool} firefox - Is running in firefox?
|
||||
* @default
|
||||
*/
|
||||
this.firefox = false;
|
||||
|
||||
/**
|
||||
* Is running in ie?
|
||||
* @type {boolean}
|
||||
* @property {bool} ie - Is running in ie?
|
||||
* @default
|
||||
*/
|
||||
this.ie = false;
|
||||
|
||||
/**
|
||||
* Version of ie?
|
||||
* @type Number
|
||||
* @property {number} ieVersion - Version of ie?
|
||||
* @default
|
||||
*/
|
||||
this.ieVersion = 0;
|
||||
|
||||
/**
|
||||
* Is running in mobileSafari?
|
||||
* @type {boolean}
|
||||
* @property {bool} mobileSafari - Is running in mobileSafari?
|
||||
* @default
|
||||
*/
|
||||
this.mobileSafari = false;
|
||||
|
||||
/**
|
||||
* Is running in midori?
|
||||
* @type {boolean}
|
||||
* @property {bool} midori - Is running in midori?
|
||||
* @default
|
||||
*/
|
||||
this.midori = false;
|
||||
|
||||
/**
|
||||
* Is running in opera?
|
||||
* @type {boolean}
|
||||
* @property {bool} opera - Is running in opera?
|
||||
* @default
|
||||
*/
|
||||
this.opera = false;
|
||||
|
||||
/**
|
||||
* Is running in safari?
|
||||
* @type {boolean}
|
||||
* @property {bool} safari - Is running in safari?
|
||||
* @default
|
||||
*/
|
||||
this.safari = false;
|
||||
this.webApp = false;
|
||||
@@ -186,75 +196,76 @@ Phaser.Device = function () {
|
||||
// Audio
|
||||
|
||||
/**
|
||||
* Are Audio tags available?
|
||||
* @type {boolean}
|
||||
* @property {bool} audioData - Are Audio tags available?
|
||||
* @default
|
||||
*/
|
||||
this.audioData = false;
|
||||
|
||||
/**
|
||||
* Is the WebAudio API available?
|
||||
* @type {boolean}
|
||||
* @property {bool} webAudio - Is the WebAudio API available?
|
||||
* @default
|
||||
*/
|
||||
this.webAudio = false;
|
||||
|
||||
/**
|
||||
* Can this device play ogg files?
|
||||
* @type {boolean}
|
||||
* @property {bool} ogg - Can this device play ogg files?
|
||||
* @default
|
||||
*/
|
||||
this.ogg = false;
|
||||
|
||||
/**
|
||||
* Can this device play opus files?
|
||||
* @type {boolean}
|
||||
* @property {bool} opus - Can this device play opus files?
|
||||
* @default
|
||||
*/
|
||||
this.opus = false;
|
||||
|
||||
/**
|
||||
* Can this device play mp3 files?
|
||||
* @type {boolean}
|
||||
* @property {bool} mp3 - Can this device play mp3 files?
|
||||
* @default
|
||||
*/
|
||||
this.mp3 = false;
|
||||
|
||||
/**
|
||||
* Can this device play wav files?
|
||||
* @type {boolean}
|
||||
* @property {bool} wav - Can this device play wav files?
|
||||
* @default
|
||||
*/
|
||||
this.wav = false;
|
||||
/**
|
||||
* Can this device play m4a files?
|
||||
* @type {boolean}
|
||||
* @property {bool} m4a - True if this device can play m4a files.
|
||||
* @default
|
||||
*/
|
||||
this.m4a = false;
|
||||
|
||||
/**
|
||||
* Can this device play webm files?
|
||||
* @type {boolean}
|
||||
* @property {bool} webm - Can this device play webm files?
|
||||
* @default
|
||||
*/
|
||||
this.webm = false;
|
||||
|
||||
// Device
|
||||
|
||||
/**
|
||||
* Is running on iPhone?
|
||||
* @type {boolean}
|
||||
* @property {bool} iPhone - Is running on iPhone?
|
||||
* @default
|
||||
*/
|
||||
this.iPhone = false;
|
||||
|
||||
/**
|
||||
* Is running on iPhone4?
|
||||
* @type {boolean}
|
||||
* @property {bool} iPhone4 - Is running on iPhone4?
|
||||
* @default
|
||||
*/
|
||||
this.iPhone4 = false;
|
||||
|
||||
/**
|
||||
* Is running on iPad?
|
||||
* @type {boolean}
|
||||
/**
|
||||
* @property {bool} iPad - Is running on iPad?
|
||||
* @default
|
||||
*/
|
||||
this.iPad = false;
|
||||
|
||||
/**
|
||||
* PixelRatio of the host device?
|
||||
* @type Number
|
||||
* @property {number} pixelRatio - PixelRatio of the host device?
|
||||
* @default
|
||||
*/
|
||||
this.pixelRatio = 0;
|
||||
|
||||
@@ -272,6 +283,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check which OS is game running on.
|
||||
* @method _checkOS
|
||||
* @private
|
||||
*/
|
||||
_checkOS: function () {
|
||||
@@ -300,6 +312,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check HTML5 features of the host environment.
|
||||
* @method _checkFeatures
|
||||
* @private
|
||||
*/
|
||||
_checkFeatures: function () {
|
||||
@@ -332,6 +345,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check what browser is game running in.
|
||||
* @method _checkBrowser
|
||||
* @private
|
||||
*/
|
||||
_checkBrowser: function () {
|
||||
@@ -368,6 +382,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check audio support.
|
||||
* @method _checkAudio
|
||||
* @private
|
||||
*/
|
||||
_checkAudio: function () {
|
||||
@@ -414,6 +429,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check PixelRatio of devices.
|
||||
* @method _checkDevice
|
||||
* @private
|
||||
*/
|
||||
_checkDevice: function () {
|
||||
@@ -427,6 +443,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check whether the host environment support 3D CSS.
|
||||
* @method _checkCSS3D
|
||||
* @private
|
||||
*/
|
||||
_checkCSS3D: function () {
|
||||
@@ -453,6 +470,11 @@ Phaser.Device.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the host environment can play audio.
|
||||
* @method canPlayAudio
|
||||
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
|
||||
*/
|
||||
canPlayAudio: function (type) {
|
||||
|
||||
if (type == 'mp3' && this.mp3) {
|
||||
@@ -471,6 +493,12 @@ Phaser.Device.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the console is open.
|
||||
* @method isConsoleOpen
|
||||
* @return {bool} True if console is open.
|
||||
*/
|
||||
|
||||
isConsoleOpen: function () {
|
||||
|
||||
if (window.console && window.console['firebug']) {
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
/**
|
||||
* Phaser - RequestAnimationFrame
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.RequestAnimationFrame
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Abstracts away the use of RAF or setTimeOut for the core game update loop.
|
||||
*
|
||||
* @class Phaser.RequestAnimationFrame
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.RequestAnimationFrame = function(game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - The currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {bool} _isSetTimeOut - Description.
|
||||
* @private
|
||||
*/
|
||||
this._isSetTimeOut = false;
|
||||
|
||||
/**
|
||||
* @property {bool} isRunning - Description.
|
||||
* @default
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
var vendors = [
|
||||
@@ -28,6 +50,7 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* The function called by the update
|
||||
* @property _onLoop
|
||||
* @private
|
||||
**/
|
||||
_onLoop: null,
|
||||
@@ -67,7 +90,8 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* The update method for the requestAnimationFrame
|
||||
* @method RAFUpdate
|
||||
* @method updateRAF
|
||||
* @param {number} time - Description.
|
||||
**/
|
||||
updateRAF: function (time) {
|
||||
|
||||
@@ -78,8 +102,8 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* The update method for the setTimeout
|
||||
* @method SetTimeoutUpdate
|
||||
* The update method for the setTimeout.
|
||||
* @method updateSetTimeout
|
||||
**/
|
||||
updateSetTimeout: function () {
|
||||
|
||||
@@ -90,7 +114,7 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the requestAnimationFrame from running
|
||||
* Stops the requestAnimationFrame from running.
|
||||
* @method stop
|
||||
**/
|
||||
stop: function () {
|
||||
@@ -111,7 +135,7 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
/**
|
||||
* Is the browser using setTimeout?
|
||||
* @method isSetTimeOut
|
||||
* @return bool
|
||||
* @return {bool}
|
||||
**/
|
||||
isSetTimeOut: function () {
|
||||
return this._isSetTimeOut;
|
||||
@@ -120,7 +144,7 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
/**
|
||||
* Is the browser using requestAnimationFrame?
|
||||
* @method isRAF
|
||||
* @return bool
|
||||
* @return {bool}
|
||||
**/
|
||||
isRAF: function () {
|
||||
return (this._isSetTimeOut === false);
|
||||
|
||||
+118
-36
@@ -1,91 +1,120 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.StageScaleMode
|
||||
*/
|
||||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.StageScaleMode
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {number} width - Description.
|
||||
* @param {number} height - Description.
|
||||
*/
|
||||
Phaser.StageScaleMode = function (game, width, height) {
|
||||
|
||||
/**
|
||||
* Stage height when start the game.
|
||||
* @type {number}
|
||||
* @property {number} _startHeight - Stage height when starting the game.
|
||||
* @default
|
||||
* @private
|
||||
*/
|
||||
this._startHeight = 0;
|
||||
|
||||
/**
|
||||
* If the game should be forced to use Landscape mode, this is set to true by Game.Stage
|
||||
* @type {bool}
|
||||
* @property {bool} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage
|
||||
* @default
|
||||
*/
|
||||
this.forceLandscape = false;
|
||||
|
||||
/**
|
||||
* If the game should be forced to use Portrait mode, this is set to true by Game.Stage
|
||||
* @type {bool}
|
||||
* @property {bool} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage
|
||||
* @default
|
||||
*/
|
||||
this.forcePortrait = false;
|
||||
this.forcePortrait = false;
|
||||
|
||||
/**
|
||||
* If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
|
||||
* @type {bool}
|
||||
* @property {bool} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
|
||||
* @default
|
||||
*/
|
||||
this.incorrectOrientation = false;
|
||||
|
||||
/**
|
||||
* If you wish to align your game in the middle of the page then you can set this value to true.
|
||||
* It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
|
||||
* It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
|
||||
* @type {bool}
|
||||
* @property {bool} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true.
|
||||
<ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.</li>
|
||||
<li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>
|
||||
* @default
|
||||
*/
|
||||
this.pageAlignHorizontally = false;
|
||||
|
||||
/**
|
||||
* If you wish to align your game in the middle of the page then you can set this value to true.
|
||||
* It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
|
||||
* It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
|
||||
* @type {bool}
|
||||
* @property {bool} pageAlignVeritcally - If you wish to align your game in the middle of the page then you can set this value to true.
|
||||
<ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
|
||||
<li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>
|
||||
* @default
|
||||
*/
|
||||
this.pageAlignVeritcally = false;
|
||||
|
||||
/**
|
||||
* Minimum width the canvas should be scaled to (in pixels)
|
||||
* @type {number}
|
||||
* @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels).
|
||||
* @default
|
||||
*/
|
||||
this.minWidth = null;
|
||||
|
||||
/**
|
||||
* Maximum width the canvas should be scaled to (in pixels).
|
||||
* @property {number} maxWidth - Maximum width the canvas should be scaled to (in pixels).
|
||||
* If null it will scale to whatever width the browser can handle.
|
||||
* @type {number}
|
||||
* @default
|
||||
*/
|
||||
this.maxWidth = null;
|
||||
|
||||
/**
|
||||
* Minimum height the canvas should be scaled to (in pixels)
|
||||
* @type {number}
|
||||
* @property {number} minHeight - Minimum height the canvas should be scaled to (in pixels).
|
||||
* @default
|
||||
*/
|
||||
this.minHeight = null;
|
||||
|
||||
/**
|
||||
* Maximum height the canvas should be scaled to (in pixels).
|
||||
* @property {number} maxHeight - Maximum height the canvas should be scaled to (in pixels).
|
||||
* If null it will scale to whatever height the browser can handle.
|
||||
* @type {number}
|
||||
* @default
|
||||
*/
|
||||
this.maxHeight = null;
|
||||
|
||||
/**
|
||||
* Width of the stage after calculation.
|
||||
* @type {number}
|
||||
* @property {number} width - Width of the stage after calculation.
|
||||
* @default
|
||||
*/
|
||||
this.width = 0;
|
||||
|
||||
/**
|
||||
* Height of the stage after calculation.
|
||||
* @type {number}
|
||||
* @property {number} height - Height of the stage after calculation.
|
||||
* @default
|
||||
*/
|
||||
this.height = 0;
|
||||
|
||||
/**
|
||||
* The maximum number of times it will try to resize the canvas to fill the browser (default is 5)
|
||||
* @type {number}
|
||||
* @property {number} maxIterations - The maximum number of times it will try to resize the canvas to fill the browser.
|
||||
* @default
|
||||
*/
|
||||
this.maxIterations = 5;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Description} enterLandscape - Description.
|
||||
*/
|
||||
this.enterLandscape = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Description} enterPortrait - Description.
|
||||
*/
|
||||
this.enterPortrait = new Phaser.Signal();
|
||||
|
||||
if (window['orientation'])
|
||||
@@ -104,7 +133,15 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {Description} scaleFactor - Description.
|
||||
*/
|
||||
this.scaleFactor = new Phaser.Point(1, 1);
|
||||
|
||||
/**
|
||||
* @property {number} aspectRatio - Aspect ratio.
|
||||
* @default
|
||||
*/
|
||||
this.aspectRatio = 0;
|
||||
|
||||
var _this = this;
|
||||
@@ -124,7 +161,10 @@ Phaser.StageScaleMode.NO_SCALE = 1;
|
||||
Phaser.StageScaleMode.SHOW_ALL = 2;
|
||||
|
||||
Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method startFullScreen
|
||||
*/
|
||||
startFullScreen: function () {
|
||||
|
||||
if (this.isFullScreen)
|
||||
@@ -152,6 +192,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method stopFullScreen
|
||||
*/
|
||||
stopFullScreen: function () {
|
||||
|
||||
if (document['cancelFullScreen'])
|
||||
@@ -169,6 +213,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method checkOrientationState
|
||||
*/
|
||||
checkOrientationState: function () {
|
||||
|
||||
// They are in the wrong orientation
|
||||
@@ -194,8 +242,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handle window.orientationchange events
|
||||
* @method checkOrientation
|
||||
* @param {Description} event - Description.
|
||||
*/
|
||||
checkOrientation: function (event) {
|
||||
|
||||
@@ -217,8 +267,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handle window.resize events
|
||||
* @method checkResize
|
||||
* @param {Description} event - Description.
|
||||
*/
|
||||
checkResize: function (event) {
|
||||
|
||||
@@ -246,8 +298,9 @@ Phaser.StageScaleMode.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Re-calculate scale mode and update screen size.
|
||||
* @method refresh
|
||||
*/
|
||||
refresh: function () {
|
||||
|
||||
@@ -280,8 +333,9 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set screen size automatically based on the scaleMode.
|
||||
* @param {Description} force - Description.
|
||||
*/
|
||||
setScreenSize: function (force) {
|
||||
|
||||
@@ -329,6 +383,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setSize
|
||||
*/
|
||||
setSize: function () {
|
||||
|
||||
if (this.incorrectOrientation == false)
|
||||
@@ -392,6 +450,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setMaximum
|
||||
*/
|
||||
setMaximum: function () {
|
||||
|
||||
this.width = window.innerWidth;
|
||||
@@ -399,6 +461,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setShowAll
|
||||
*/
|
||||
setShowAll: function () {
|
||||
|
||||
var multiplier = Math.min((window.innerHeight / this.game.height), (window.innerWidth / this.game.width));
|
||||
@@ -408,6 +474,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setExactFit
|
||||
*/
|
||||
setExactFit: function () {
|
||||
|
||||
var availableWidth = window.innerWidth - 0;
|
||||
@@ -439,6 +509,10 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {bool}
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
|
||||
|
||||
get: function () {
|
||||
@@ -454,6 +528,10 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
|
||||
|
||||
get: function () {
|
||||
@@ -462,6 +540,10 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {number}
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
|
||||
|
||||
get: function () {
|
||||
|
||||
Reference in New Issue
Block a user