mirror of
https://github.com/wassname/phaser.git
synced 2026-08-02 13:00:25 +08:00
More Docs!
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
/**
|
||||
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
|
||||
*
|
||||
* @class Phaser.Animation.Parser
|
||||
* @class Phaser.AnimationParser
|
||||
*/
|
||||
Phaser.Animation.Parser = {
|
||||
Phaser.AnimationParser = {
|
||||
|
||||
/**
|
||||
* Parse a Sprite Sheet and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.Animation.Parser.spriteSheet
|
||||
* @method Phaser.AnimationParser.spriteSheet
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {string} key - The Game.Cache asset key of the Sprite Sheet image.
|
||||
* @param {number} frameWidth - The fixed width of each frame of the animation.
|
||||
@@ -57,7 +57,7 @@ Phaser.Animation.Parser = {
|
||||
// Zero or smaller than frame sizes?
|
||||
if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
|
||||
{
|
||||
console.warn("Phaser.Animation.Parser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight");
|
||||
console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.Animation.Parser.JSONData
|
||||
* @method Phaser.AnimationParser.JSONData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
@@ -106,7 +106,7 @@ Phaser.Animation.Parser = {
|
||||
// Malformed?
|
||||
if (!json['frames'])
|
||||
{
|
||||
console.warn("Phaser.Animation.Parser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array");
|
||||
console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array");
|
||||
console.log(json);
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.Animation.Parser.JSONDataHash
|
||||
* @method Phaser.AnimationParser.JSONDataHash
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
@@ -177,7 +177,7 @@ Phaser.Animation.Parser = {
|
||||
// Malformed?
|
||||
if (!json['frames'])
|
||||
{
|
||||
console.warn("Phaser.Animation.Parser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object");
|
||||
console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object");
|
||||
console.log(json);
|
||||
return;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ Phaser.Animation.Parser = {
|
||||
/**
|
||||
* Parse the XML data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.Animation.Parser.XMLData
|
||||
* @method Phaser.AnimationParser.XMLData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
@@ -251,7 +251,7 @@ Phaser.Animation.Parser = {
|
||||
// Malformed?
|
||||
if (!xml.getElementsByTagName('TextureAtlas'))
|
||||
{
|
||||
console.warn("Phaser.Animation.Parser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
|
||||
console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
|
||||
* The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y
|
||||
*
|
||||
|
||||
+5
-5
@@ -114,7 +114,7 @@ Phaser.Cache.prototype = {
|
||||
PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
|
||||
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
|
||||
|
||||
this._images[key].frameData = Phaser.Animation.Parser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax);
|
||||
this._images[key].frameData = Phaser.AnimationParser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax);
|
||||
|
||||
},
|
||||
|
||||
@@ -156,15 +156,15 @@ Phaser.Cache.prototype = {
|
||||
|
||||
if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY)
|
||||
{
|
||||
this._images[key].frameData = Phaser.Animation.Parser.JSONData(this.game, atlasData, key);
|
||||
this._images[key].frameData = Phaser.AnimationParser.JSONData(this.game, atlasData, key);
|
||||
}
|
||||
else if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH)
|
||||
{
|
||||
this._images[key].frameData = Phaser.Animation.Parser.JSONDataHash(this.game, atlasData, key);
|
||||
this._images[key].frameData = Phaser.AnimationParser.JSONDataHash(this.game, atlasData, key);
|
||||
}
|
||||
else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
|
||||
{
|
||||
this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, atlasData, key);
|
||||
this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, atlasData, key);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -186,7 +186,7 @@ Phaser.Cache.prototype = {
|
||||
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
|
||||
|
||||
Phaser.Loader.Parser.bitmapFont(this.game, xmlData, key);
|
||||
// this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, xmlData, key);
|
||||
// this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, xmlData, key);
|
||||
|
||||
},
|
||||
|
||||
|
||||
+15
-18
@@ -600,10 +600,10 @@ Phaser.Sound.prototype = {
|
||||
/**
|
||||
* Restart the sound, or a marked section of it.
|
||||
* @method Phaser.Sound#restart
|
||||
* @param {string} marker - Assets key of the sound you want to play.
|
||||
* @param {number} position - The starting position.
|
||||
* @param {number} [volume] - Volume of the sound you want to play.
|
||||
* @param {boolean} [loop] - Loop when it finished playing? (Default to false)
|
||||
* @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound.
|
||||
* @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker.
|
||||
* @param {number} [volume=1] - Volume of the sound you want to play.
|
||||
* @param {boolean} [loop=false] - Loop when it finished playing?
|
||||
*/
|
||||
restart: function (marker, position, volume, loop) {
|
||||
|
||||
@@ -700,8 +700,9 @@ Phaser.Sound.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {boolean} Description.
|
||||
* @name Phaser.Sound#isDecoding
|
||||
* @property {boolean} isDecoding - Returns true if the sound file is still decoding.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sound.prototype, "isDecoding", {
|
||||
|
||||
@@ -712,8 +713,9 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoding", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {boolean} Description.
|
||||
* @name Phaser.Sound#isDecoded
|
||||
* @property {boolean} isDecoded - Returns true if the sound file has decoded.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sound.prototype, "isDecoded", {
|
||||
|
||||
@@ -724,11 +726,8 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {boolean} Whether or not the sound is muted.
|
||||
*//**
|
||||
* Mutes sound.
|
||||
* @param {boolean} value - Whether or not the sound is muted.
|
||||
* @name Phaser.Sound#mute
|
||||
* @property {boolean} mute - Gets or sets the muted state of this sound.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sound.prototype, "mute", {
|
||||
|
||||
@@ -776,11 +775,9 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the current volume. A value between 0 (silence) and 1 (full volume).
|
||||
* @return {number}
|
||||
*//**
|
||||
* Set
|
||||
* @param {number} value - Sets the current volume. A value between 0 (silence) and 1 (full volume).
|
||||
* @name Phaser.Sound#volume
|
||||
* @property {number} volume - Gets or sets the volume of this sound, a value between 0 and 1.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sound.prototype, "volume", {
|
||||
|
||||
|
||||
+17
-27
@@ -2,10 +2,8 @@
|
||||
* @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.SoundManager
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Sound Manager constructor.
|
||||
*
|
||||
@@ -96,7 +94,8 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* Initialises the sound manager.
|
||||
* @method boot
|
||||
* @method Phaser.SoundManager#boot
|
||||
* @protected
|
||||
*/
|
||||
boot: function () {
|
||||
|
||||
@@ -178,7 +177,7 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* Enables the audio, usually after the first touch.
|
||||
* @method unlock
|
||||
* @method Phaser.SoundManager#unlock
|
||||
*/
|
||||
unlock: function () {
|
||||
|
||||
@@ -212,7 +211,7 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* Stops all the sounds in the game.
|
||||
* @method stopAll
|
||||
* @method Phaser.SoundManager#stopAll
|
||||
*/
|
||||
stopAll: function () {
|
||||
|
||||
@@ -228,7 +227,7 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* Pauses all the sounds in the game.
|
||||
* @method pauseAll
|
||||
* @method Phaser.SoundManager#pauseAll
|
||||
*/
|
||||
pauseAll: function () {
|
||||
|
||||
@@ -244,7 +243,7 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* resumes every sound in the game.
|
||||
* @method resumeAll
|
||||
* @method Phaser.SoundManager#resumeAll
|
||||
*/
|
||||
resumeAll: function () {
|
||||
|
||||
@@ -259,8 +258,8 @@ Phaser.SoundManager.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Decode a sound with its assets key.
|
||||
* @method decode
|
||||
* Decode a sound by its assets key.
|
||||
* @method Phaser.SoundManager#decode
|
||||
* @param {string} key - Assets key of the sound to be decoded.
|
||||
* @param {Phaser.Sound} [sound] - Its buffer will be set to decoded data.
|
||||
*/
|
||||
@@ -292,7 +291,7 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
/**
|
||||
* Updates every sound in the game.
|
||||
* @method update
|
||||
* @method Phaser.SoundManager#update
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
@@ -317,21 +316,18 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method add
|
||||
* Adds a new Sound into the SoundManager.
|
||||
* @method Phaser.SoundManager#add
|
||||
* @param {string} key - Asset key for the sound.
|
||||
* @param {number} volume - Default value for the volume.
|
||||
* @param {boolean} loop - Whether or not the sound will loop.
|
||||
* @param {number} [volume=1] - Default value for the volume.
|
||||
* @param {boolean} [loop=false] - Whether or not the sound will loop.
|
||||
*/
|
||||
add: function (key, volume, loop) {
|
||||
|
||||
volume = volume || 1;
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
|
||||
|
||||
|
||||
var sound = new Phaser.Sound(this.game, key, volume, loop);
|
||||
|
||||
this._sounds.push(sound);
|
||||
@@ -343,11 +339,8 @@ Phaser.SoundManager.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* A global audio mute toggle.
|
||||
* @return {boolean} Whether or not the game is on "mute".
|
||||
*//**
|
||||
* Mute sounds.
|
||||
* @param {boolean} value - Whether or not the game is on "mute"
|
||||
* @name Phaser.SoundManager#mute
|
||||
* @property {boolean} mute - Gets or sets the muted state of the SoundManager. This effects all sounds in the game.
|
||||
*/
|
||||
Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
|
||||
|
||||
@@ -413,11 +406,8 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume).
|
||||
*//**
|
||||
* Sets the global volume
|
||||
* @return {number} value - The global audio volume. A value between 0 (silence) and 1 (full volume).
|
||||
* @name Phaser.SoundManager#volume
|
||||
* @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1.
|
||||
*/
|
||||
Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
|
||||
|
||||
|
||||
+22
-12
@@ -2,20 +2,20 @@
|
||||
* @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.Canvas
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
|
||||
*
|
||||
* @class Canvas
|
||||
* @class Phaser.Canvas
|
||||
* @static
|
||||
*/
|
||||
Phaser.Canvas = {
|
||||
|
||||
/**
|
||||
* Creates the <canvas> tag
|
||||
*
|
||||
* @method create
|
||||
* @method Phaser.Canvas.create
|
||||
* @param {number} width - The desired width.
|
||||
* @param {number} height - The desired height.
|
||||
* @return {HTMLCanvasElement} The newly created <canvas> tag.
|
||||
@@ -35,7 +35,7 @@ Phaser.Canvas = {
|
||||
|
||||
/**
|
||||
* Get the DOM offset values of any given element
|
||||
* @method getOffset
|
||||
* @method Phaser.Canvas.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 {Phaser.Point} - A point objet with the offsetX and Y as its properties.
|
||||
@@ -60,7 +60,7 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Returns the aspect ratio of the given canvas.
|
||||
*
|
||||
* @method getAspectRatio
|
||||
* @method Phaser.Canvas.getAspectRatio
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
|
||||
* @return {number} The ratio between canvas' width and height.
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Sets the background color behind the canvas. This changes the canvas style property.
|
||||
*
|
||||
* @method setBackgroundColor
|
||||
* @method Phaser.Canvas.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.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
@@ -89,7 +89,7 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*
|
||||
* @method setTouchAction
|
||||
* @method Phaser.Canvas.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} The source canvas.
|
||||
@@ -106,8 +106,18 @@ Phaser.Canvas = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
|
||||
*
|
||||
* @method Phaser.Canvas.setUserSelect
|
||||
* @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.
|
||||
*/
|
||||
setUserSelect: function (canvas, value) {
|
||||
|
||||
value = value || 'none';
|
||||
|
||||
canvas.style['-webkit-touch-callout'] = value;
|
||||
canvas.style['-webkit-user-select'] = value;
|
||||
canvas.style['-khtml-user-select'] = value;
|
||||
@@ -124,7 +134,7 @@ Phaser.Canvas = {
|
||||
* Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent.
|
||||
* If no parent is given it will be added as a child of the document.body.
|
||||
*
|
||||
* @method addToDOM
|
||||
* @method Phaser.Canvas.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 {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
@@ -164,7 +174,7 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Sets the transform of the given canvas to the matrix values provided.
|
||||
*
|
||||
* @method setTransform
|
||||
* @method Phaser.Canvas.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.
|
||||
@@ -189,7 +199,7 @@ Phaser.Canvas = {
|
||||
* drawn to the context will be affected. This sets the property across all current browsers but support is
|
||||
* patchy on earlier browsers, especially on mobile.
|
||||
*
|
||||
* @method setSmoothingEnabled
|
||||
* @method Phaser.Canvas.setSmoothingEnabled
|
||||
* @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
|
||||
* @param {boolean} value - If set to true it will enable image smoothing, false will disable it.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
@@ -210,7 +220,7 @@ Phaser.Canvas = {
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit').
|
||||
* Note that if this doesn't given the desired result then see the setSmoothingEnabled.
|
||||
*
|
||||
* @method setImageRenderingCrisp
|
||||
* @method Phaser.Canvas.setImageRenderingCrisp
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
@@ -229,7 +239,7 @@ Phaser.Canvas = {
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
|
||||
* Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
|
||||
*
|
||||
* @method setImageRenderingBicubic
|
||||
* @method Phaser.Canvas.setImageRenderingBicubic
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
|
||||
+34
-23
@@ -2,13 +2,10 @@
|
||||
* @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
|
||||
* {@link https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js}
|
||||
*
|
||||
* @class Phaser.Device
|
||||
* @constructor
|
||||
@@ -17,8 +14,7 @@
|
||||
Phaser.Device = function () {
|
||||
|
||||
/**
|
||||
* An optional 'fix' for the horrendous Android stock browser bug
|
||||
* {@link https://code.google.com/p/android/issues/detail?id=39247}
|
||||
* An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247
|
||||
* @property {boolean} patchAndroidClearRectBug - Description.
|
||||
* @default
|
||||
*/
|
||||
@@ -283,7 +279,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check which OS is game running on.
|
||||
* @method _checkOS
|
||||
* @method Phaser.Device#_checkOS
|
||||
* @private
|
||||
*/
|
||||
_checkOS: function () {
|
||||
@@ -312,7 +308,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check HTML5 features of the host environment.
|
||||
* @method _checkFeatures
|
||||
* @method Phaser.Device#_checkFeatures
|
||||
* @private
|
||||
*/
|
||||
_checkFeatures: function () {
|
||||
@@ -345,7 +341,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check what browser is game running in.
|
||||
* @method _checkBrowser
|
||||
* @method Phaser.Device#_checkBrowser
|
||||
* @private
|
||||
*/
|
||||
_checkBrowser: function () {
|
||||
@@ -382,7 +378,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check audio support.
|
||||
* @method _checkAudio
|
||||
* @method Phaser.Device#_checkAudio
|
||||
* @private
|
||||
*/
|
||||
_checkAudio: function () {
|
||||
@@ -429,7 +425,7 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check PixelRatio of devices.
|
||||
* @method _checkDevice
|
||||
* @method Phaser.Device#_checkDevice
|
||||
* @private
|
||||
*/
|
||||
_checkDevice: function () {
|
||||
@@ -443,10 +439,11 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check whether the host environment support 3D CSS.
|
||||
* @method _checkCSS3D
|
||||
* @method Phaser.Device#_checkCSS3D
|
||||
* @private
|
||||
*/
|
||||
_checkCSS3D: function () {
|
||||
|
||||
var el = document.createElement('p');
|
||||
var has3d;
|
||||
var transforms = {
|
||||
@@ -456,6 +453,7 @@ Phaser.Device.prototype = {
|
||||
'MozTransform': '-moz-transform',
|
||||
'transform': 'transform'
|
||||
};
|
||||
|
||||
// Add it to the body to get the computed style.
|
||||
document.body.insertBefore(el, null);
|
||||
|
||||
@@ -465,6 +463,7 @@ Phaser.Device.prototype = {
|
||||
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.removeChild(el);
|
||||
this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
|
||||
|
||||
@@ -472,20 +471,30 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check whether the host environment can play audio.
|
||||
* @method canPlayAudio
|
||||
* @method Phaser.Device#canPlayAudio
|
||||
* @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
|
||||
* @return {boolean} True if the given file type is supported by the browser, otherwise false.
|
||||
*/
|
||||
canPlayAudio: function (type) {
|
||||
|
||||
if (type == 'mp3' && this.mp3) {
|
||||
if (type == 'mp3' && this.mp3)
|
||||
{
|
||||
return true;
|
||||
} else if (type == 'ogg' && (this.ogg || this.opus)) {
|
||||
}
|
||||
else if (type == 'ogg' && (this.ogg || this.opus))
|
||||
{
|
||||
return true;
|
||||
} else if (type == 'm4a' && this.m4a) {
|
||||
}
|
||||
else if (type == 'm4a' && this.m4a)
|
||||
{
|
||||
return true;
|
||||
} else if (type == 'wav' && this.wav) {
|
||||
}
|
||||
else if (type == 'wav' && this.wav)
|
||||
{
|
||||
return true;
|
||||
} else if (type == 'webm' && this.webm) {
|
||||
}
|
||||
else if (type == 'webm' && this.webm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -495,21 +504,23 @@ Phaser.Device.prototype = {
|
||||
|
||||
/**
|
||||
* Check whether the console is open.
|
||||
* @method isConsoleOpen
|
||||
* @return {boolean} True if console is open.
|
||||
* @method Phaser.Device#isConsoleOpen
|
||||
* @return {boolean} True if the browser dev console is open.
|
||||
*/
|
||||
|
||||
isConsoleOpen: function () {
|
||||
|
||||
if (window.console && window.console['firebug']) {
|
||||
if (window.console && window.console['firebug'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (window.console) {
|
||||
if (window.console)
|
||||
{
|
||||
console.profile();
|
||||
console.profileEnd();
|
||||
|
||||
if (console.clear) {
|
||||
if (console.clear)
|
||||
{
|
||||
console.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
* @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.
|
||||
*
|
||||
@@ -39,26 +37,28 @@ Phaser.RequestAnimationFrame = function(game) {
|
||||
'o'
|
||||
];
|
||||
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) {
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
|
||||
{
|
||||
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* The function called by the update
|
||||
* @property _onLoop
|
||||
* @private
|
||||
**/
|
||||
_onLoop: null,
|
||||
*/
|
||||
this._onLoop = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
|
||||
/**
|
||||
* Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
|
||||
* @method start
|
||||
**/
|
||||
* @method Phaser.RequestAnimationFrame#start
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
this.isRunning = true;
|
||||
@@ -90,9 +90,9 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* The update method for the requestAnimationFrame
|
||||
* @method updateRAF
|
||||
* @param {number} time - Description.
|
||||
**/
|
||||
* @method Phaser.RequestAnimationFrame#updateRAF
|
||||
* @param {number} time - A timestamp, either from RAF or setTimeOut
|
||||
*/
|
||||
updateRAF: function (time) {
|
||||
|
||||
this.game.update(time);
|
||||
@@ -103,8 +103,8 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* The update method for the setTimeout.
|
||||
* @method updateSetTimeout
|
||||
**/
|
||||
* @method Phaser.RequestAnimationFrame#updateSetTimeout
|
||||
*/
|
||||
updateSetTimeout: function () {
|
||||
|
||||
this.game.update(Date.now());
|
||||
@@ -115,8 +115,8 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* Stops the requestAnimationFrame from running.
|
||||
* @method stop
|
||||
**/
|
||||
* @method Phaser.RequestAnimationFrame#stop
|
||||
*/
|
||||
stop: function () {
|
||||
|
||||
if (this._isSetTimeOut)
|
||||
@@ -134,18 +134,18 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* Is the browser using setTimeout?
|
||||
* @method isSetTimeOut
|
||||
* @method Phaser.RequestAnimationFrame#isSetTimeOut
|
||||
* @return {boolean}
|
||||
**/
|
||||
*/
|
||||
isSetTimeOut: function () {
|
||||
return this._isSetTimeOut;
|
||||
},
|
||||
|
||||
/**
|
||||
* Is the browser using requestAnimationFrame?
|
||||
* @method isRAF
|
||||
* @method Phaser.RequestAnimationFrame#isRAF
|
||||
* @return {boolean}
|
||||
**/
|
||||
*/
|
||||
isRAF: function () {
|
||||
return (this._isSetTimeOut === false);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -156,14 +155,30 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.StageScaleMode.EXACT_FIT = 0;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.StageScaleMode.NO_SCALE = 1;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.StageScaleMode.SHOW_ALL = 2;
|
||||
|
||||
Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method startFullScreen
|
||||
* Tries to enter the browser into full screen mode.
|
||||
* Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser.
|
||||
* @method Phaser.StageScaleMode#startFullScreen
|
||||
*/
|
||||
startFullScreen: function () {
|
||||
|
||||
@@ -193,8 +208,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method stopFullScreen
|
||||
* Stops full screen mode if the browser is in it.
|
||||
* @method Phaser.StageScaleMode#stopFullScreen
|
||||
*/
|
||||
stopFullScreen: function () {
|
||||
|
||||
@@ -214,8 +229,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method checkOrientationState
|
||||
* Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set)
|
||||
* @method Phaser.StageScaleMode#checkOrientationState
|
||||
*/
|
||||
checkOrientationState: function () {
|
||||
|
||||
@@ -244,8 +259,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Handle window.orientationchange events
|
||||
* @method checkOrientation
|
||||
* @param {Description} event - Description.
|
||||
* @method Phaser.StageScaleMode#checkOrientation
|
||||
* @param {Event} event - The orientationchange event data.
|
||||
*/
|
||||
checkOrientation: function (event) {
|
||||
|
||||
@@ -269,8 +284,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Handle window.resize events
|
||||
* @method checkResize
|
||||
* @param {Description} event - Description.
|
||||
* @method Phaser.StageScaleMode#checkResize
|
||||
* @param {Event} event - The resize event data.
|
||||
*/
|
||||
checkResize: function (event) {
|
||||
|
||||
@@ -300,7 +315,7 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Re-calculate scale mode and update screen size.
|
||||
* @method refresh
|
||||
* @method Phaser.StageScaleMode#refresh
|
||||
*/
|
||||
refresh: function () {
|
||||
|
||||
@@ -335,7 +350,7 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
/**
|
||||
* Set screen size automatically based on the scaleMode.
|
||||
* @param {Description} force - Description.
|
||||
* @param {Description} force - If force is true it will try to resize the game regardless of the document dimensions.
|
||||
*/
|
||||
setScreenSize: function (force) {
|
||||
|
||||
@@ -384,8 +399,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setSize
|
||||
* Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height.
|
||||
* @method Phaser.StageScaleMode#setSize
|
||||
*/
|
||||
setSize: function () {
|
||||
|
||||
@@ -451,8 +466,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setMaximum
|
||||
* Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight
|
||||
* @method Phaser.StageScaleMode#setMaximum
|
||||
*/
|
||||
setMaximum: function () {
|
||||
|
||||
@@ -462,8 +477,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setShowAll
|
||||
* Calculates the multiplier needed to scale the game proportionally.
|
||||
* @method Phaser.StageScaleMode#setShowAll
|
||||
*/
|
||||
setShowAll: function () {
|
||||
|
||||
@@ -475,15 +490,15 @@ Phaser.StageScaleMode.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method setExactFit
|
||||
* Sets the width and height values of the canvas, no larger than the maxWidth/Height.
|
||||
* @method Phaser.StageScaleMode#setExactFit
|
||||
*/
|
||||
setExactFit: function () {
|
||||
|
||||
var availableWidth = window.innerWidth - 0;
|
||||
var availableHeight = window.innerHeight - 5;
|
||||
|
||||
console.log('available', availableWidth, availableHeight);
|
||||
// console.log('available', availableWidth, availableHeight);
|
||||
|
||||
if (this.maxWidth && availableWidth > this.maxWidth)
|
||||
{
|
||||
@@ -510,8 +525,9 @@ Phaser.StageScaleMode.prototype = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {boolean}
|
||||
* @name Phaser.StageScaleMode#isFullScreen
|
||||
* @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
|
||||
|
||||
@@ -529,8 +545,9 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {number}
|
||||
* @name Phaser.StageScaleMode#isPortrait
|
||||
* @property {boolean} isPortrait - Returns true if the browser dimensions match a portrait display.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
|
||||
|
||||
@@ -541,8 +558,9 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @return {number}
|
||||
* @name Phaser.StageScaleMode#isLandscape
|
||||
* @property {boolean} isLandscape - Returns true if the browser dimensions match a landscape display.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
|
||||
|
||||
@@ -551,4 +569,3 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user