mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
The entire Phaser library has been updated to match the new JSHint configuration.
This commit is contained in:
parent
13a2cc2feb
commit
299115ca5d
74 changed files with 4992 additions and 4977 deletions
|
@ -42,6 +42,7 @@ Change Log
|
|||
Version 1.1.3 - in build
|
||||
|
||||
* New: Added a .jshintrc so contributions can be run through JSHint to help retain formatting across the library (thanks kevinthompson)
|
||||
* New: The entire Phaser library has been updated to match the new JSHint configuration.
|
||||
* New: Added a new in-built texture. Sprites now use __default if no texture was provided (a 32x32 transparent PNG) or __missing if one was given but not found (a 32x32 black box with a green cross through it)
|
||||
* New: Added Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports.
|
||||
* New: The object returned by Math.sinCosGenerator now contains a length property.
|
||||
|
@ -84,13 +85,12 @@ Version 1.1.3 - in build
|
|||
* Updated: Tided up the Graphics object (thanks BorisKozo)
|
||||
* Updated: If running in Canvas mode and you have a render function it will save the context and reset the transform before running your render function.
|
||||
* Updated: Sprite will now check the exists property of the Group it is in, if the Group.exists = false the Sprite won't update.
|
||||
* Updated: Lots of documentation tweaks across various files such as Pointer, Sound and Color.
|
||||
* Updated: Lots of documentation fixes and updates across nearly all files.
|
||||
* Updated: If you specify 'null' as a Group parent it will now revert to using the World as the parent (before only 'undefined' worked)
|
||||
* Updated: Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist (thanks cocoademon)
|
||||
* Updated: Loader.audio can now accept either an array of URL strings or a single URL string (thanks crazysam + kevinthompson)
|
||||
* Updated: MSPointer updated to support IE11 by dropping the prefix from the event listeners.
|
||||
|
||||
|
||||
You can view the complete Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
|
||||
How to Build
|
||||
|
|
|
@ -141,8 +141,10 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
|
||||
PIXI.WebGLBatch.prototype.update = function()
|
||||
{
|
||||
var gl = this.gl;
|
||||
var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3
|
||||
// var gl = this.gl;
|
||||
// var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3
|
||||
|
||||
var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index;
|
||||
|
||||
var a, b, c, d, tx, ty;
|
||||
|
||||
|
|
|
@ -21,10 +21,14 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
|||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
|
||||
text = text || '';
|
||||
style = style || '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||
* @default
|
||||
|
@ -38,53 +42,51 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
|||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Description} group - Description.
|
||||
* @default
|
||||
* @property {Phaser.Group} group - The parent Group of this BitmapText.
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - Description.
|
||||
* @property {string} name - The user defined name given to this BitmapText.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
* @property {number} type - The const type of this object.
|
||||
* @readonly
|
||||
*/
|
||||
this.game = game;
|
||||
this.type = Phaser.BITMAPTEXT;
|
||||
|
||||
PIXI.BitmapText.call(this, text, style);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.BITMAPTEXT;
|
||||
|
||||
/**
|
||||
* @property {number} position.x - Description.
|
||||
* @property {number} position.x - The x position of this object.
|
||||
*/
|
||||
this.position.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} position.y - Description.
|
||||
* @property {number} position.y - The y position of this object.
|
||||
*/
|
||||
this.position.y = y;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
/**
|
||||
* @property {Phaser.Point} anchor - Description.
|
||||
* The anchor sets the origin point of the texture.
|
||||
* The default is 0,0 this means the textures origin is the top left
|
||||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} scale - Description.
|
||||
* @property {Phaser.Point} scale - The scale of the object when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
|
||||
*/
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// A mini cache for storing all of the calculated values
|
||||
/**
|
||||
* @property {function} _cache - Description.
|
||||
* @property {object} _cache - A mini cache for storing all of the calculated values.
|
||||
* @private
|
||||
*/
|
||||
this._cache = {
|
||||
|
@ -114,15 +116,13 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
|||
this._cache.y = this.y;
|
||||
|
||||
/**
|
||||
* @property {boolean} renderable - Description.
|
||||
* @private
|
||||
* @property {boolean} renderable - A renderable object will be rendered to the context each frame.
|
||||
*/
|
||||
this.renderable = true;
|
||||
|
||||
};
|
||||
|
||||
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
||||
// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
|
||||
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
||||
|
||||
/**
|
||||
|
@ -180,11 +180,11 @@ Phaser.BitmapText.prototype.destroy = function() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
* Indicates the rotation of the BitmapText, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
|
||||
* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
|
||||
* @name Phaser.BitmapText#angle
|
||||
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||
|
||||
|
@ -199,11 +199,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
|||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
* The x coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#x
|
||||
* @property {number} x - The x coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||
|
||||
|
@ -218,11 +216,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
|||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
* The y coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#y
|
||||
* @property {number} y - The y coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
|
||||
|
||||
|
|
|
@ -165,17 +165,17 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place.
|
||||
* @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {number} x - The x coordinate (in world space) of this Sprite.
|
||||
* @property {number} x - The x coordinate in world space of this Sprite.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} y - The y coordinate (in world space) of this Sprite.
|
||||
* @property {number} y - The y coordinate in world space of this Sprite.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
|
|
|
@ -27,24 +27,24 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
|
||||
* @property {boolean} alive - This is a handy little var your game can use to determine if an object is alive or not, it doesn't effect rendering.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.
|
||||
* @property {Phaser.Group} group - The parent Group of this Text object.
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this Sprite.
|
||||
* @property {string} name - The user defined name given to this object.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
@ -81,7 +81,7 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place.
|
||||
* @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
|
@ -182,11 +182,11 @@ Phaser.Text.prototype.destroy = function() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
* Indicates the rotation of the Text, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
|
||||
* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
|
||||
* @name Phaser.Text#angle
|
||||
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, 'angle', {
|
||||
|
||||
|
@ -200,6 +200,45 @@ Object.defineProperty(Phaser.Text.prototype, 'angle', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* The x coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#x
|
||||
* @property {number} x - The x coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||
|
||||
get: function() {
|
||||
return this.position.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The y coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#y
|
||||
* @property {number} y - The y coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
|
||||
|
||||
get: function() {
|
||||
return this.position.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The string to be rendered by this Text object.
|
||||
* @name Phaser.Text#content
|
||||
* @property {string} content - The string to be rendered by this Text object.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, 'content', {
|
||||
|
||||
get: function() {
|
||||
|
@ -219,6 +258,11 @@ Object.defineProperty(Phaser.Text.prototype, 'content', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* The font the text will be rendered in.
|
||||
* @name Phaser.Text#font
|
||||
* @property {string} font - The font the text will be rendered in.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, 'font', {
|
||||
|
||||
get: function() {
|
||||
|
|
|
@ -72,9 +72,9 @@ Phaser.Cache = function (game) {
|
|||
this.addMissingImage();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onSoundUnlock - Description.
|
||||
* @property {Phaser.Signal} onSoundUnlock - This event is dispatched when the sound system is unlocked via a touch event on cellular devices.
|
||||
*/
|
||||
this.onSoundUnlock = new Phaser.Signal;
|
||||
this.onSoundUnlock = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
|
@ -326,7 +326,6 @@ Phaser.Cache.prototype = {
|
|||
webAudio = webAudio || true;
|
||||
audioTag = audioTag || false;
|
||||
|
||||
var locked = this.game.sound.touchLocked;
|
||||
var decoded = false;
|
||||
|
||||
if (audioTag)
|
||||
|
|
|
@ -95,22 +95,22 @@ Phaser.Loader = function (game) {
|
|||
/**
|
||||
* @property {Phaser.Signal} onFileComplete - Event signal.
|
||||
*/
|
||||
this.onFileComplete = new Phaser.Signal;
|
||||
this.onFileComplete = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onFileError - Event signal.
|
||||
*/
|
||||
this.onFileError = new Phaser.Signal;
|
||||
this.onFileError = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onLoadStart - Event signal.
|
||||
*/
|
||||
this.onLoadStart = new Phaser.Signal;
|
||||
this.onLoadStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onLoadComplete - Event signal.
|
||||
*/
|
||||
this.onLoadComplete = new Phaser.Signal;
|
||||
this.onLoadComplete = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1072,8 +1072,15 @@ Phaser.Math = {
|
|||
*/
|
||||
smoothstep: function ( x, min, max ) {
|
||||
|
||||
if ( x <= min ) return 0;
|
||||
if ( x >= max ) return 1;
|
||||
if (x <= min)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x >= max)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
x = (x - min) / (max - min);
|
||||
|
||||
|
@ -1092,8 +1099,15 @@ Phaser.Math = {
|
|||
*/
|
||||
smootherstep: function ( x, min, max ) {
|
||||
|
||||
if ( x <= min ) return 0;
|
||||
if ( x >= max ) return 1;
|
||||
if (x <= min)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x >= max)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
x = (x - min) / (max - min);
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ Phaser.QuadTree.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* jshint noempty: false */
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
|
@ -19,41 +21,41 @@ Phaser.RandomDataGenerator = function (seeds) {
|
|||
|
||||
if (typeof seeds === "undefined") { seeds = []; }
|
||||
|
||||
/**
|
||||
* @property {number} c - Internal var.
|
||||
* @private
|
||||
*/
|
||||
this.c = 1;
|
||||
|
||||
/**
|
||||
* @property {number} s0 - Internal var.
|
||||
* @private
|
||||
*/
|
||||
this.s0 = 0;
|
||||
|
||||
/**
|
||||
* @property {number} s1 - Internal var.
|
||||
* @private
|
||||
*/
|
||||
this.s1 = 0;
|
||||
|
||||
/**
|
||||
* @property {number} s2 - Internal var.
|
||||
* @private
|
||||
*/
|
||||
this.s2 = 0;
|
||||
|
||||
this.sow(seeds);
|
||||
|
||||
};
|
||||
|
||||
Phaser.RandomDataGenerator.prototype = {
|
||||
|
||||
/**
|
||||
* @property {number} c
|
||||
* @private
|
||||
*/
|
||||
c: 1,
|
||||
|
||||
/**
|
||||
* @property {number} s0
|
||||
* @private
|
||||
*/
|
||||
s0: 0,
|
||||
|
||||
/**
|
||||
* @property {number} s1
|
||||
* @private
|
||||
*/
|
||||
s1: 0,
|
||||
|
||||
/**
|
||||
* @property {number} s2
|
||||
* @private
|
||||
*/
|
||||
s2: 0,
|
||||
|
||||
/**
|
||||
* Private random helper.
|
||||
* @method Phaser.RandomDataGenerator#rnd
|
||||
* @private
|
||||
* @return {number} Description.
|
||||
* @return {number}
|
||||
*/
|
||||
rnd: function () {
|
||||
|
||||
|
@ -97,11 +99,11 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* Internal method that creates a seed hash.
|
||||
* @method Phaser.RandomDataGenerator#hash
|
||||
* @param {Any} data
|
||||
* @private
|
||||
* @return {number} Description.
|
||||
* @return {number} hashed value.
|
||||
*/
|
||||
hash: function (data) {
|
||||
|
||||
|
@ -127,7 +129,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random integer between 0 and 2^32.
|
||||
* @method Phaser.RandomDataGenerator#integer
|
||||
* @return {number}
|
||||
* @return {number} A random integer between 0 and 2^32.
|
||||
*/
|
||||
integer: function() {
|
||||
return this.rnd.apply(this) * 0x100000000;// 2^32
|
||||
|
@ -136,7 +138,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random real number between 0 and 1.
|
||||
* @method Phaser.RandomDataGenerator#frac
|
||||
* @return {number}
|
||||
* @return {number} A random real number between 0 and 1.
|
||||
*/
|
||||
frac: function() {
|
||||
return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53
|
||||
|
@ -145,7 +147,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random real number between 0 and 2^32.
|
||||
* @method Phaser.RandomDataGenerator#real
|
||||
* @return {number}
|
||||
* @return {number} A random real number between 0 and 2^32.
|
||||
*/
|
||||
real: function() {
|
||||
return this.integer() + this.frac();
|
||||
|
@ -154,9 +156,9 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random integer between min and max.
|
||||
* @method Phaser.RandomDataGenerator#integerInRange
|
||||
* @param {number} min
|
||||
* @param {number} max
|
||||
* @return {number}
|
||||
* @param {number} min - The minimum value in the range.
|
||||
* @param {number} max - The maximum value in the range.
|
||||
* @return {number} A random number between min and max.
|
||||
*/
|
||||
integerInRange: function (min, max) {
|
||||
return Math.floor(this.realInRange(min, max));
|
||||
|
@ -165,9 +167,9 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random real number between min and max.
|
||||
* @method Phaser.RandomDataGenerator#realInRange
|
||||
* @param {number} min
|
||||
* @param {number} max
|
||||
* @return {number}
|
||||
* @param {number} min - The minimum value in the range.
|
||||
* @param {number} max - The maximum value in the range.
|
||||
* @return {number} A random number between min and max.
|
||||
*/
|
||||
realInRange: function (min, max) {
|
||||
|
||||
|
@ -178,7 +180,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random real number between -1 and 1.
|
||||
* @method Phaser.RandomDataGenerator#normal
|
||||
* @return {number}
|
||||
* @return {number} A random real number between -1 and 1.
|
||||
*/
|
||||
normal: function () {
|
||||
return 1 - 2 * this.frac();
|
||||
|
@ -187,17 +189,16 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
|
||||
* @method Phaser.RandomDataGenerator#uuid
|
||||
* @return {string}
|
||||
* @return {string} A valid RFC4122 version4 ID hex string
|
||||
*/
|
||||
uuid: function () {
|
||||
|
||||
var a, b;
|
||||
var a = '';
|
||||
var b = '';
|
||||
|
||||
for (
|
||||
b=a='';
|
||||
a++<36;
|
||||
b+=~a%5|a*3&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):'-'
|
||||
);
|
||||
for (b = a = ''; a++ < 36; b +=~a % 5 | a * 3&4 ? (a^15 ? 8^this.frac() * (a^20 ? 16 : 4) : 4).toString(16) : '-')
|
||||
{
|
||||
}
|
||||
|
||||
return b;
|
||||
|
||||
|
@ -206,8 +207,8 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random member of `array`.
|
||||
* @method Phaser.RandomDataGenerator#pick
|
||||
* @param {Any} ary
|
||||
* @return {number}
|
||||
* @param {Array} ary - An Array to pick a random member of.
|
||||
* @return {any} A random member of the array.
|
||||
*/
|
||||
pick: function (ary) {
|
||||
return ary[this.integerInRange(0, ary.length)];
|
||||
|
@ -216,8 +217,8 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random member of `array`, favoring the earlier entries.
|
||||
* @method Phaser.RandomDataGenerator#weightedPick
|
||||
* @param {Any} ary
|
||||
* @return {number}
|
||||
* @param {Array} ary - An Array to pick a random member of.
|
||||
* @return {any} A random member of the array.
|
||||
*/
|
||||
weightedPick: function (ary) {
|
||||
return ary[~~(Math.pow(this.frac(), 2) * ary.length)];
|
||||
|
@ -226,18 +227,18 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
/**
|
||||
* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
|
||||
* @method Phaser.RandomDataGenerator#timestamp
|
||||
* @param {number} min
|
||||
* @param {number} max
|
||||
* @return {number}
|
||||
* @param {number} min - The minimum value in the range.
|
||||
* @param {number} max - The maximum value in the range.
|
||||
* @return {number} A random timestamp between min and max.
|
||||
*/
|
||||
timestamp: function (a, b) {
|
||||
return this.realInRange(a || 946684800000, b || 1577862000000);
|
||||
timestamp: function (min, max) {
|
||||
return this.realInRange(min || 946684800000, max || 1577862000000);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a random angle between -180 and 180.
|
||||
* @method Phaser.RandomDataGenerator#angle
|
||||
* @return {number}
|
||||
* @return {number} A random number between -180 and 180.
|
||||
*/
|
||||
angle: function() {
|
||||
return this.integerInRange(-180, 180);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Description of Phaser.Net
|
||||
* Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation.
|
||||
*
|
||||
* @class Phaser.Net
|
||||
* @constructor
|
||||
|
@ -43,7 +43,7 @@ Phaser.Net.prototype = {
|
|||
*
|
||||
* @method Phaser.Net#checkDomainName
|
||||
* @param {string} domain
|
||||
* @return {boolean}
|
||||
* @return {boolean} true if the given domain fragment can be found in the window.location.hostname
|
||||
*/
|
||||
checkDomainName: function (domain) {
|
||||
return window.location.hostname.indexOf(domain) !== -1;
|
||||
|
@ -65,11 +65,7 @@ Phaser.Net.prototype = {
|
|||
updateQueryString: function (key, value, redirect, url) {
|
||||
|
||||
if (typeof redirect === "undefined") { redirect = false; }
|
||||
if (typeof url === "undefined") { url = ''; }
|
||||
|
||||
if (url == '') {
|
||||
url = window.location.href;
|
||||
}
|
||||
if (typeof url === "undefined" || url === '') { url = window.location.href; }
|
||||
|
||||
var output = '';
|
||||
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
||||
|
|
|
@ -15,12 +15,17 @@
|
|||
Phaser.Particles = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Description} emitters - Description.
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {object} emitters - Internal emitters store.
|
||||
*/
|
||||
this.emitters = {};
|
||||
|
||||
/**
|
||||
* @property {number} ID - Description.
|
||||
* @property {number} ID -
|
||||
* @default
|
||||
*/
|
||||
this.ID = 0;
|
||||
|
@ -32,7 +37,7 @@ Phaser.Particles.prototype = {
|
|||
/**
|
||||
* Adds a new Particle Emitter to the Particle Manager.
|
||||
* @method Phaser.Particles#add
|
||||
* @param {Phaser.Emitter} emitter - Description.
|
||||
* @param {Phaser.Emitter} emitter - The emitter to be added to the particle manager.
|
||||
* @return {Phaser.Emitter} The emitter that was added.
|
||||
*/
|
||||
add: function (emitter) {
|
||||
|
|
|
@ -315,10 +315,10 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
|
|||
|
||||
particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
// else
|
||||
// {
|
||||
// particle = new this.particleClass(this.game);
|
||||
}
|
||||
// }
|
||||
|
||||
if (collide > 0)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ Phaser.Physics.Arcade = function (game) {
|
|||
/**
|
||||
* @property {Phaser.Point} gravity - The World gravity setting. Defaults to x: 0, y: 0, or no gravity.
|
||||
*/
|
||||
this.gravity = new Phaser.Point;
|
||||
this.gravity = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds.
|
||||
|
@ -65,13 +65,13 @@ Phaser.Physics.Arcade = function (game) {
|
|||
* @property {Phaser.Rectangle} _bounds1 - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._bounds1 = new Phaser.Rectangle;
|
||||
this._bounds1 = new Phaser.Rectangle();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} _bounds2 - Internal cache var.
|
||||
* @private
|
||||
*/
|
||||
this._bounds2 = new Phaser.Rectangle;
|
||||
this._bounds2 = new Phaser.Rectangle();
|
||||
|
||||
/**
|
||||
* @property {number} _overlap - Internal cache var.
|
||||
|
@ -658,7 +658,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
}
|
||||
|
||||
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (this._overlap != 0)
|
||||
if (this._overlap !== 0)
|
||||
{
|
||||
body1.overlapX = this._overlap;
|
||||
body2.overlapX = this._overlap;
|
||||
|
@ -766,7 +766,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
}
|
||||
|
||||
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (this._overlap != 0)
|
||||
if (this._overlap !== 0)
|
||||
{
|
||||
body1.overlapY = this._overlap;
|
||||
body2.overlapY = this._overlap;
|
||||
|
@ -894,7 +894,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
}
|
||||
|
||||
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (this._overlap != 0)
|
||||
if (this._overlap !== 0)
|
||||
{
|
||||
if (separate)
|
||||
{
|
||||
|
@ -980,7 +980,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
}
|
||||
|
||||
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (this._overlap != 0)
|
||||
if (this._overlap !== 0)
|
||||
{
|
||||
if (separate)
|
||||
{
|
||||
|
@ -1133,7 +1133,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
velocityFromAngle: function (angle, speed, point) {
|
||||
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
return point.setTo((Math.cos(this.game.math.degToRad(angle)) * speed), (Math.sin(this.game.math.degToRad(angle)) * speed));
|
||||
|
||||
|
@ -1152,7 +1152,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
velocityFromRotation: function (rotation, speed, point) {
|
||||
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
accelerationFromRotation: function (rotation, speed, point) {
|
||||
|
||||
if (typeof speed === 'undefined') { speed = 60; }
|
||||
point = point || new Phaser.Point;
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|||
/**
|
||||
* @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
|
||||
*/
|
||||
this.offset = new Phaser.Point;
|
||||
this.offset = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {number} x - The x position of the physics body.
|
||||
|
@ -124,27 +124,27 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|||
/**
|
||||
* @property {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body.
|
||||
*/
|
||||
this.velocity = new Phaser.Point;
|
||||
this.velocity = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body.
|
||||
*/
|
||||
this.acceleration = new Phaser.Point;
|
||||
this.acceleration = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} drag - The drag applied to the motion of the Body.
|
||||
*/
|
||||
this.drag = new Phaser.Point;
|
||||
this.drag = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} gravity - A private Gravity setting for the Body.
|
||||
*/
|
||||
this.gravity = new Phaser.Point;
|
||||
this.gravity = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.
|
||||
*/
|
||||
this.bounce = new Phaser.Point;
|
||||
this.bounce = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach.
|
||||
|
|
|
@ -27,157 +27,128 @@ Phaser.Sound = function (game, key, volume, loop) {
|
|||
this.game = game;
|
||||
|
||||
/**
|
||||
* Name of the sound.
|
||||
* @property {string} name
|
||||
* @default
|
||||
* @property {string} name - Name of the sound.
|
||||
*/
|
||||
this.name = key;
|
||||
|
||||
/**
|
||||
* Asset key for the sound.
|
||||
* @property {string} key
|
||||
* @property {string} key - Asset key for the sound.
|
||||
*/
|
||||
this.key = key;
|
||||
|
||||
/**
|
||||
* Whether or not the sound will loop.
|
||||
* @property {boolean} loop
|
||||
* @property {boolean} loop - Whether or not the sound will loop.
|
||||
*/
|
||||
this.loop = loop;
|
||||
|
||||
/**
|
||||
* The global audio volume. A value between 0 (silence) and 1 (full volume).
|
||||
* @property {number} _volume
|
||||
* @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume).
|
||||
* @private
|
||||
*/
|
||||
this._volume = volume;
|
||||
|
||||
/**
|
||||
* The sound markers, empty by default.
|
||||
* @property {object} markers
|
||||
* @property {object} markers - The sound markers.
|
||||
*/
|
||||
this.markers = {};
|
||||
|
||||
|
||||
/**
|
||||
* Reference to AudioContext instance.
|
||||
* @property {AudioContext} context
|
||||
* @default
|
||||
* @property {AudioContext} context - Reference to the AudioContext instance.
|
||||
*/
|
||||
this.context = null;
|
||||
|
||||
/**
|
||||
* Decoded data buffer / Audio tag.
|
||||
* @property {Description} _buffer
|
||||
* @property {Description} _buffer - Decoded data buffer / Audio tag.
|
||||
* @private
|
||||
*/
|
||||
this._buffer = null;
|
||||
|
||||
/**
|
||||
* Boolean indicating whether the game is on "mute".
|
||||
* @property {boolean} _muted
|
||||
* @property {boolean} _muted - Boolean indicating whether the sound is muted or not.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._muted = false;
|
||||
|
||||
/**
|
||||
* Boolean indicating whether the sound should start automatically.
|
||||
* @property {boolean} autoplay
|
||||
* @private
|
||||
* @property {boolean} autoplay - Boolean indicating whether the sound should start automatically.
|
||||
*/
|
||||
this.autoplay = false;
|
||||
|
||||
/**
|
||||
* The total duration of the sound, in milliseconds
|
||||
* @property {number} totalDuration
|
||||
* @default
|
||||
* @property {number} totalDuration - The total duration of the sound, in milliseconds
|
||||
*/
|
||||
this.totalDuration = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} startTime
|
||||
* @property {number} startTime - The time the Sound starts at (typically 0 unless starting from a marker)
|
||||
* @default
|
||||
*/
|
||||
this.startTime = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} currentTime
|
||||
* @default
|
||||
* @property {number} currentTime - The current time the sound is at.
|
||||
*/
|
||||
this.currentTime = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} duration
|
||||
* @default
|
||||
* @property {number} duration - The duration of the sound.
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} stopTime
|
||||
* @property {number} stopTime - The time the sound stopped.
|
||||
*/
|
||||
this.stopTime = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {boolean} paused
|
||||
* @property {boolean} paused - true if the sound is paused, otherwise false.
|
||||
* @default
|
||||
*/
|
||||
this.paused = false;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} pausedPosition
|
||||
* @property {number} pausedPosition - The position the sound had reached when it was paused.
|
||||
*/
|
||||
this.pausedPosition = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {number} pausedTime
|
||||
* @property {number} pausedTime - The game time at which the sound was paused.
|
||||
*/
|
||||
this.pausedTime = 0;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {boolean} isPlaying
|
||||
* @property {boolean} isPlaying - true if the sound is currently playing, otherwise false.
|
||||
* @default
|
||||
*/
|
||||
this.isPlaying = false;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {string} currentMarker
|
||||
* @property {string} currentMarker - The string ID of the currently playing marker, if any.
|
||||
* @default
|
||||
*/
|
||||
this.currentMarker = '';
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {boolean} pendingPlayback
|
||||
* @default
|
||||
* @property {boolean} pendingPlayback - true if the sound file is pending playback
|
||||
* @readonly
|
||||
*/
|
||||
this.pendingPlayback = false;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {boolean} override
|
||||
* @property {boolean} override - if true when you play this sound it will always start from the beginning.
|
||||
* @default
|
||||
*/
|
||||
this.override = false;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {boolean} usingWebAudio
|
||||
* @property {boolean} usingWebAudio - true if this sound is being played with Web Audio.
|
||||
* @readonly
|
||||
*/
|
||||
this.usingWebAudio = this.game.sound.usingWebAudio;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Description} usingAudioTag
|
||||
* @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag.
|
||||
*/
|
||||
this.usingAudioTag = this.game.sound.usingAudioTag;
|
||||
|
||||
|
@ -217,52 +188,44 @@ Phaser.Sound = function (game, key, volume, loop) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onDecoded
|
||||
* @property {Phaser.Signal} onDecoded - The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files)
|
||||
*/
|
||||
this.onDecoded = new Phaser.Signal;
|
||||
this.onDecoded = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onPlay
|
||||
* @property {Phaser.Signal} onPlay - The onPlay event is dispatched each time this sound is played.
|
||||
*/
|
||||
this.onPlay = new Phaser.Signal;
|
||||
this.onPlay = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onPause
|
||||
* @property {Phaser.Signal} onPause - The onPause event is dispatched when this sound is paused.
|
||||
*/
|
||||
this.onPause = new Phaser.Signal;
|
||||
this.onPause = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onResume
|
||||
* @property {Phaser.Signal} onResume - The onResume event is dispatched when this sound is resumed from a paused state.
|
||||
*/
|
||||
this.onResume = new Phaser.Signal;
|
||||
this.onResume = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onLoop
|
||||
* @property {Phaser.Signal} onLoop - The onLoop event is dispatched when this sound loops during playback.
|
||||
*/
|
||||
this.onLoop = new Phaser.Signal;
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onStop
|
||||
* @property {Phaser.Signal} onStop - The onStop event is dispatched when this sound stops playback.
|
||||
*/
|
||||
this.onStop = new Phaser.Signal;
|
||||
this.onStop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onMute
|
||||
* @property {Phaser.Signal} onMute - The onMouse event is dispatched when this sound is muted.
|
||||
*/
|
||||
this.onMute = new Phaser.Signal;
|
||||
this.onMute = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @property {Phaser.Signal} onMarkerComplete
|
||||
* @property {Phaser.Signal} onMarkerComplete - The onMarkerComplete event is dispatched when a marker within this sound completes playback.
|
||||
*/
|
||||
this.onMarkerComplete = new Phaser.Signal;
|
||||
this.onMarkerComplete = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
|
@ -271,7 +234,7 @@ Phaser.Sound.prototype = {
|
|||
/**
|
||||
* Called automatically when this sound is unlocked.
|
||||
* @method Phaser.Sound#soundHasUnlocked
|
||||
* @param {string} key - Description.
|
||||
* @param {string} key - The Phaser.Cache key of the sound file to check for decoding.
|
||||
* @protected
|
||||
*/
|
||||
soundHasUnlocked: function (key) {
|
||||
|
@ -377,7 +340,7 @@ Phaser.Sound.prototype = {
|
|||
// won't work with markers, needs to reset the position
|
||||
this.onLoop.dispatch(this);
|
||||
|
||||
if (this.currentMarker == '')
|
||||
if (this.currentMarker === '')
|
||||
{
|
||||
//console.log('loop2');
|
||||
this.currentTime = 0;
|
||||
|
@ -524,7 +487,7 @@ Phaser.Sound.prototype = {
|
|||
this.durationMS = this.totalDuration * 1000;
|
||||
}
|
||||
|
||||
if (this.loop && marker == '')
|
||||
if (this.loop && marker === '')
|
||||
{
|
||||
this._sound.loop = true;
|
||||
}
|
||||
|
|
|
@ -22,19 +22,19 @@ Phaser.SoundManager = function (game) {
|
|||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onSoundDecode - Description.
|
||||
* @property {Phaser.Signal} onSoundDecode - The event dispatched when a sound decodes (typically only for mp3 files)
|
||||
*/
|
||||
this.onSoundDecode = new Phaser.Signal;
|
||||
this.onSoundDecode = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} _muted - Description.
|
||||
* @property {boolean} _muted - Internal mute tracking var.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._muted = false;
|
||||
|
||||
/**
|
||||
* @property {Description} _unlockSource - Description.
|
||||
* @property {Description} _unlockSource - Internal unlock tracking var.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
|
@ -55,37 +55,37 @@ Phaser.SoundManager = function (game) {
|
|||
this._sounds = [];
|
||||
|
||||
/**
|
||||
* @property {Description} context - Description.
|
||||
* @property {AudioContext} context - The AudioContext being used for playback.
|
||||
* @default
|
||||
*/
|
||||
this.context = null;
|
||||
|
||||
/**
|
||||
* @property {boolean} usingWebAudio - Description.
|
||||
* @default
|
||||
* @property {boolean} usingWebAudio - true if this sound is being played with Web Audio.
|
||||
* @readonly
|
||||
*/
|
||||
this.usingWebAudio = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} usingAudioTag - Description.
|
||||
* @default
|
||||
* @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag.
|
||||
* @readonly
|
||||
*/
|
||||
this.usingAudioTag = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} noAudio - Description.
|
||||
* @property {boolean} noAudio - Has audio been disabled via the PhaserGlobal object? Useful if you need to use a 3rd party audio library instead.
|
||||
* @default
|
||||
*/
|
||||
this.noAudio = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} touchLocked - Description.
|
||||
* @property {boolean} touchLocked - true if the audio system is currently locked awaiting a touch event.
|
||||
* @default
|
||||
*/
|
||||
this.touchLocked = false;
|
||||
|
||||
/**
|
||||
* @property {number} channels - Description.
|
||||
* @property {number} channels - The number of audio channels to use in playback.
|
||||
* @default
|
||||
*/
|
||||
this.channels = 32;
|
||||
|
|
|
@ -43,7 +43,7 @@ Phaser.Canvas = {
|
|||
*/
|
||||
getOffset: function (element, point) {
|
||||
|
||||
point = point || new Phaser.Point;
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||
|
|
|
@ -387,7 +387,7 @@ Phaser.Device.prototype = {
|
|||
this.mobileSafari = true;
|
||||
} else if (/MSIE (\d+\.\d+);/.test(ua)) {
|
||||
this.ie = true;
|
||||
this.ieVersion = parseInt(RegExp.$1);
|
||||
this.ieVersion = parseInt(RegExp.$1, 10);
|
||||
} else if (/Midori/.test(ua)) {
|
||||
this.midori = true;
|
||||
} else if (/Opera/.test(ua)) {
|
||||
|
|
|
@ -188,6 +188,11 @@ Phaser.StageScaleMode = function (game, width, height) {
|
|||
*/
|
||||
this.aspectRatio = 0;
|
||||
|
||||
/**
|
||||
* @property {any} event- The native browser events from full screen API changes.
|
||||
*/
|
||||
this.event = null;
|
||||
|
||||
var _this = this;
|
||||
|
||||
window.addEventListener('orientationchange', function (event) {
|
||||
|
@ -301,6 +306,8 @@ Phaser.StageScaleMode.prototype = {
|
|||
*/
|
||||
fullScreenChange: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (this.isFullScreen)
|
||||
{
|
||||
this.game.stage.canvas.style['width'] = '100%';
|
||||
|
@ -429,6 +436,8 @@ Phaser.StageScaleMode.prototype = {
|
|||
*/
|
||||
checkOrientation: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
this.orientation = window['orientation'];
|
||||
|
||||
if (this.isLandscape)
|
||||
|
@ -454,6 +463,8 @@ Phaser.StageScaleMode.prototype = {
|
|||
*/
|
||||
checkResize: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (window.outerWidth > window.outerHeight)
|
||||
{
|
||||
this.orientation = 90;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* @module Phaser.Tile
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create a new <code>Tile</code>.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,7 @@ Phaser.Tilemap = function (game, key) {
|
|||
/**
|
||||
* @property {array} layers - Description.
|
||||
*/
|
||||
this.layers;
|
||||
this.layers = null;
|
||||
|
||||
if (typeof key === 'string')
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ Phaser.Tilemap.prototype = {
|
|||
|
||||
},
|
||||
|
||||
swapHandler: function (value, index, array) {
|
||||
swapHandler: function (value, index) {
|
||||
|
||||
if (value.index === this._tempA)
|
||||
{
|
||||
|
|
|
@ -256,9 +256,9 @@ Phaser.TilemapLayer.prototype._fixX = function(x) {
|
|||
return x;
|
||||
}
|
||||
|
||||
var left_edge = x - (this._x / this.scrollFactorX);
|
||||
var leftEdge = x - (this._x / this.scrollFactorX);
|
||||
|
||||
return this._x + left_edge;
|
||||
return this._x + leftEdge;
|
||||
|
||||
}
|
||||
|
||||
|
@ -275,9 +275,9 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) {
|
|||
return x;
|
||||
}
|
||||
|
||||
var left_edge = x - this._x;
|
||||
var leftEdge = x - this._x;
|
||||
|
||||
return (this._x / this.scrollFactorX) + left_edge;
|
||||
return (this._x / this.scrollFactorX) + leftEdge;
|
||||
|
||||
}
|
||||
|
||||
|
@ -294,9 +294,9 @@ Phaser.TilemapLayer.prototype._fixY = function(y) {
|
|||
return y;
|
||||
}
|
||||
|
||||
var top_edge = y - (this._y / this.scrollFactorY);
|
||||
var topEdge = y - (this._y / this.scrollFactorY);
|
||||
|
||||
return this._y + top_edge;
|
||||
return this._y + topEdge;
|
||||
|
||||
}
|
||||
|
||||
|
@ -313,9 +313,9 @@ Phaser.TilemapLayer.prototype._unfixY = function(y) {
|
|||
return y;
|
||||
}
|
||||
|
||||
var top_edge = y - this._y;
|
||||
var topEdge = y - this._y;
|
||||
|
||||
return (this._y / this.scrollFactorY) + top_edge;
|
||||
return (this._y / this.scrollFactorY) + topEdge;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ Phaser.TilemapParser = {
|
|||
|
||||
for (var c = 0; c < column.length; c++)
|
||||
{
|
||||
output[i][c] = parseInt(column[c]);
|
||||
output[i][c] = parseInt(column[c], 10);
|
||||
}
|
||||
|
||||
if (width === 0)
|
||||
|
@ -145,7 +145,7 @@ Phaser.TilemapParser = {
|
|||
indexes: [],
|
||||
|
||||
tileMargin: json.tilesets[0].margin,
|
||||
tileSpacing: json.tilesets[0].spacing,
|
||||
tileSpacing: json.tilesets[0].spacing
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ Phaser.Tileset.prototype = {
|
|||
this.tiles[index].setCollision(left, right, up, down);
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,124 +20,91 @@ Phaser.Time = function (game) {
|
|||
this.game = game;
|
||||
|
||||
/**
|
||||
* The time at which the Game instance started.
|
||||
* @property {number} _started
|
||||
* @property {number} _started - The time at which the Game instance started.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._started = 0;
|
||||
|
||||
/**
|
||||
* The time (in ms) that the last second counter ticked over.
|
||||
* @property {number} _timeLastSecond
|
||||
* @property {number} _timeLastSecond - The time (in ms) that the last second counter ticked over.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._timeLastSecond = 0;
|
||||
|
||||
/**
|
||||
* The time the game started being paused.
|
||||
* @property {number} _pauseStarted
|
||||
* @property {number} _pauseStarted - The time the game started being paused.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._pauseStarted = 0;
|
||||
|
||||
/**
|
||||
* The elapsed time calculated for the physics motion updates.
|
||||
* @property {number} physicsElapsed
|
||||
* @default
|
||||
* @property {number} physicsElapsed - The elapsed time calculated for the physics motion updates.
|
||||
*/
|
||||
this.physicsElapsed = 0;
|
||||
|
||||
/**
|
||||
* Game time counter.
|
||||
* @property {number} time
|
||||
* @default
|
||||
* @property {number} time - Game time counter.
|
||||
*/
|
||||
this.time = 0;
|
||||
|
||||
/**
|
||||
* Records how long the game has been paused for. Is reset each time the game pauses.
|
||||
* @property {number} pausedTime
|
||||
* @default
|
||||
* @property {number} pausedTime - Records how long the game has been paused for. Is reset each time the game pauses.
|
||||
*/
|
||||
this.pausedTime = 0;
|
||||
|
||||
/**
|
||||
* The time right now.
|
||||
* @property {number} now
|
||||
* @default
|
||||
* @property {number} now - The time right now.
|
||||
*/
|
||||
this.now = 0;
|
||||
|
||||
/**
|
||||
* Elapsed time since the last frame.
|
||||
* @property {number} elapsed
|
||||
* @default
|
||||
* @property {number} elapsed - Elapsed time since the last frame.
|
||||
*/
|
||||
this.elapsed = 0;
|
||||
|
||||
/**
|
||||
* Frames per second.
|
||||
* @property {number} fps
|
||||
* @default
|
||||
* @property {number} fps - Frames per second.
|
||||
*/
|
||||
this.fps = 0;
|
||||
|
||||
/**
|
||||
* The lowest rate the fps has dropped to.
|
||||
* @property {number} fpsMin
|
||||
* @default
|
||||
* @property {number} fpsMin - The lowest rate the fps has dropped to.
|
||||
*/
|
||||
this.fpsMin = 1000;
|
||||
|
||||
/**
|
||||
* The highest rate the fps has reached (usually no higher than 60fps).
|
||||
* @property {number} fpsMax
|
||||
* @default
|
||||
* @property {number} fpsMax - The highest rate the fps has reached (usually no higher than 60fps).
|
||||
*/
|
||||
this.fpsMax = 0;
|
||||
|
||||
/**
|
||||
* The minimum amount of time the game has taken between two frames.
|
||||
* @property {number} msMin
|
||||
* @property {number} msMin - The minimum amount of time the game has taken between two frames.
|
||||
* @default
|
||||
*/
|
||||
this.msMin = 1000;
|
||||
|
||||
/**
|
||||
* The maximum amount of time the game has taken between two frames.
|
||||
* @property {number} msMax
|
||||
* @default
|
||||
* @property {number} msMax - The maximum amount of time the game has taken between two frames.
|
||||
*/
|
||||
this.msMax = 0;
|
||||
|
||||
/**
|
||||
* The number of frames record in the last second.
|
||||
* @property {number} frames
|
||||
* @default
|
||||
* @property {number} frames - The number of frames record in the last second.
|
||||
*/
|
||||
this.frames = 0;
|
||||
|
||||
/**
|
||||
* Records how long the game was paused for in miliseconds.
|
||||
* @property {number} pauseDuration
|
||||
* @default
|
||||
* @property {number} pauseDuration - Records how long the game was paused for in miliseconds.
|
||||
*/
|
||||
this.pauseDuration = 0;
|
||||
|
||||
/**
|
||||
* The value that setTimeout needs to work out when to next update
|
||||
* @property {number} timeToCall
|
||||
* @default
|
||||
* @property {number} timeToCall - The value that setTimeout needs to work out when to next update
|
||||
*/
|
||||
this.timeToCall = 0;
|
||||
|
||||
/**
|
||||
* Internal value used by timeToCall as part of the setTimeout loop
|
||||
* @property {number} lastTime
|
||||
* @default
|
||||
* @property {number} lastTime - Internal value used by timeToCall as part of the setTimeout loop
|
||||
*/
|
||||
this.lastTime = 0;
|
||||
|
||||
|
@ -146,9 +113,8 @@ Phaser.Time = function (game) {
|
|||
this.game.onResume.add(this.gameResumed, this);
|
||||
|
||||
/**
|
||||
* Internal value used to recover from the game pause state.
|
||||
* @property {boolean} _justResumed
|
||||
* @default
|
||||
* @property {boolean} _justResumed - Internal value used to recover from the game pause state.
|
||||
* @private
|
||||
*/
|
||||
this._justResumed = false;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* jshint curly: false */
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
|
|
|
@ -241,10 +241,9 @@ Phaser.Tween.prototype = {
|
|||
* Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
|
||||
*
|
||||
* @method Phaser.Tween#start
|
||||
* @param {number} time - Description.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
start: function ( time ) {
|
||||
start: function () {
|
||||
|
||||
if (this.game === null || this._object === null) {
|
||||
return;
|
||||
|
|
|
@ -126,7 +126,10 @@ Phaser.TweenManager.prototype = {
|
|||
*/
|
||||
update: function () {
|
||||
|
||||
if ( this._tweens.length === 0 && this._add.length === 0 ) return false;
|
||||
if ( this._tweens.length === 0 && this._add.length === 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var numTweens = this._tweens.length;
|
||||
|
@ -182,7 +185,7 @@ Phaser.TweenManager.prototype = {
|
|||
|
||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||
this._tweens[i].pause();
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
@ -195,7 +198,7 @@ Phaser.TweenManager.prototype = {
|
|||
|
||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||
this._tweens[i].resume();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* jshint supernew: true */
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
|
@ -47,6 +49,8 @@ Phaser.Utils = {
|
|||
if (typeof(pad) == "undefined") { var pad = ' '; }
|
||||
if (typeof(dir) == "undefined") { var dir = 3; }
|
||||
|
||||
var padlen = 0;
|
||||
|
||||
if (len + 1 >= str.length)
|
||||
{
|
||||
switch (dir)
|
||||
|
@ -200,7 +204,7 @@ Phaser.Utils = {
|
|||
if (consoleDisabled) {
|
||||
window.console = undefined;
|
||||
}
|
||||
if (window.console == undefined) {
|
||||
if (window.console === undefined) {
|
||||
window.console = {
|
||||
debug: function() {
|
||||
return true;
|
||||
|
@ -244,12 +248,19 @@ function HEXtoRGB(hex) {
|
|||
* A polyfill for Function.prototype.bind
|
||||
*/
|
||||
if (typeof Function.prototype.bind != 'function') {
|
||||
|
||||
Function.prototype.bind = (function () {
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
return function (thisArg) {
|
||||
|
||||
var target = this, boundArgs = slice.call(arguments, 1);
|
||||
|
||||
if (typeof target != 'function') throw new TypeError();
|
||||
if (typeof target != 'function')
|
||||
{
|
||||
throw new TypeError();
|
||||
}
|
||||
|
||||
function bound() {
|
||||
var args = boundArgs.concat(slice.call(arguments));
|
||||
|
@ -258,11 +269,14 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
|
||||
bound.prototype = (function F(proto) {
|
||||
proto && (F.prototype = proto);
|
||||
if (!(this instanceof F)) return new F;
|
||||
|
||||
if (!(this instanceof F))
|
||||
{
|
||||
return new F;
|
||||
}
|
||||
})(target.prototype);
|
||||
|
||||
return bound;
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue