mirror of
https://github.com/photonstorm/phaser
synced 2024-12-03 09:59:42 +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
|
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: 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 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: 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.
|
* 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: 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: 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: 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: 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: 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: 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.
|
* 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
|
You can view the complete Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||||
|
|
||||||
How to Build
|
How to Build
|
||||||
|
|
|
@ -141,8 +141,10 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
||||||
|
|
||||||
PIXI.WebGLBatch.prototype.update = function()
|
PIXI.WebGLBatch.prototype.update = function()
|
||||||
{
|
{
|
||||||
var gl = this.gl;
|
// 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, index2, index3
|
||||||
|
|
||||||
|
var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index;
|
||||||
|
|
||||||
var a, b, c, d, tx, ty;
|
var a, b, c, d, tx, ty;
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,14 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
||||||
|
|
||||||
x = x || 0;
|
x = x || 0;
|
||||||
y = y || 0;
|
y = y || 0;
|
||||||
|
|
||||||
text = text || '';
|
text = text || '';
|
||||||
style = style || '';
|
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.
|
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||||
* @default
|
* @default
|
||||||
|
@ -38,53 +42,51 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
||||||
this.alive = true;
|
this.alive = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Description} group - Description.
|
* @property {Phaser.Group} group - The parent Group of this BitmapText.
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.group = null;
|
this.group = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {string} name - Description.
|
* @property {string} name - The user defined name given to this BitmapText.
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.name = '';
|
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);
|
PIXI.BitmapText.call(this, text, style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Description} type - Description.
|
* @property {number} position.x - The x position of this object.
|
||||||
*/
|
|
||||||
this.type = Phaser.BITMAPTEXT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property {number} position.x - Description.
|
|
||||||
*/
|
*/
|
||||||
this.position.x = x;
|
this.position.x = x;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} position.y - Description.
|
* @property {number} position.y - The y position of this object.
|
||||||
*/
|
*/
|
||||||
this.position.y = y;
|
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();
|
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);
|
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
|
* @private
|
||||||
*/
|
*/
|
||||||
this._cache = {
|
this._cache = {
|
||||||
|
@ -114,15 +116,13 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
||||||
this._cache.y = this.y;
|
this._cache.y = this.y;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} renderable - Description.
|
* @property {boolean} renderable - A renderable object will be rendered to the context each frame.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
this.renderable = true;
|
this.renderable = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
||||||
// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
|
|
||||||
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,11 +180,11 @@ Phaser.BitmapText.prototype.destroy = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* 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.
|
||||||
* @returns {Description}
|
* 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.
|
||||||
* Set
|
* @name Phaser.BitmapText#angle
|
||||||
* @param {Description} value - Description
|
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||||
|
|
||||||
|
@ -199,11 +199,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* The x coordinate of this object in world space.
|
||||||
* @returns {Description}
|
* @name Phaser.BitmapText#x
|
||||||
*//**
|
* @property {number} x - The x coordinate of this object in world space.
|
||||||
* Set
|
|
||||||
* @param {Description} value - Description
|
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||||
|
|
||||||
|
@ -218,11 +216,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* The y coordinate of this object in world space.
|
||||||
* @returns {Description}
|
* @name Phaser.BitmapText#y
|
||||||
*//**
|
* @property {number} y - The y coordinate of this object in world space.
|
||||||
* Set
|
|
||||||
* @param {Description} value - Description
|
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
|
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 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
|
* 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();
|
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;
|
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;
|
this.y = y;
|
||||||
|
|
||||||
|
|
|
@ -27,24 +27,24 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||||
this.game = 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.
|
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.exists = true;
|
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
|
* @default
|
||||||
*/
|
*/
|
||||||
this.alive = true;
|
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;
|
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
|
* @default
|
||||||
*/
|
*/
|
||||||
this.name = '';
|
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 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
|
* 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();
|
this.anchor = new Phaser.Point();
|
||||||
|
|
||||||
|
@ -182,11 +182,11 @@ Phaser.Text.prototype.destroy = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* 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.
|
||||||
* @returns {Description}
|
* 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.
|
||||||
* Set
|
* @name Phaser.Text#angle
|
||||||
* @param {Description} value - Description
|
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(Phaser.Text.prototype, 'angle', {
|
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', {
|
Object.defineProperty(Phaser.Text.prototype, 'content', {
|
||||||
|
|
||||||
get: function() {
|
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', {
|
Object.defineProperty(Phaser.Text.prototype, 'font', {
|
||||||
|
|
||||||
get: function() {
|
get: function() {
|
||||||
|
|
|
@ -72,9 +72,9 @@ Phaser.Cache = function (game) {
|
||||||
this.addMissingImage();
|
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;
|
webAudio = webAudio || true;
|
||||||
audioTag = audioTag || false;
|
audioTag = audioTag || false;
|
||||||
|
|
||||||
var locked = this.game.sound.touchLocked;
|
|
||||||
var decoded = false;
|
var decoded = false;
|
||||||
|
|
||||||
if (audioTag)
|
if (audioTag)
|
||||||
|
|
|
@ -95,22 +95,22 @@ Phaser.Loader = function (game) {
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Signal} onFileComplete - Event signal.
|
* @property {Phaser.Signal} onFileComplete - Event signal.
|
||||||
*/
|
*/
|
||||||
this.onFileComplete = new Phaser.Signal;
|
this.onFileComplete = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Signal} onFileError - Event signal.
|
* @property {Phaser.Signal} onFileError - Event signal.
|
||||||
*/
|
*/
|
||||||
this.onFileError = new Phaser.Signal;
|
this.onFileError = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Signal} onLoadStart - Event signal.
|
* @property {Phaser.Signal} onLoadStart - Event signal.
|
||||||
*/
|
*/
|
||||||
this.onLoadStart = new Phaser.Signal;
|
this.onLoadStart = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Signal} onLoadComplete - Event signal.
|
* @property {Phaser.Signal} onLoadComplete - Event signal.
|
||||||
*/
|
*/
|
||||||
this.onLoadComplete = new Phaser.Signal;
|
this.onLoadComplete = new Phaser.Signal();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1072,12 +1072,19 @@ Phaser.Math = {
|
||||||
*/
|
*/
|
||||||
smoothstep: function ( x, min, max ) {
|
smoothstep: function ( x, min, max ) {
|
||||||
|
|
||||||
if ( x <= min ) return 0;
|
if (x <= min)
|
||||||
if ( x >= max ) return 1;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
x = ( x - min )/( max - min );
|
if (x >= max)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return x*x*(3 - 2*x);
|
x = (x - min) / (max - min);
|
||||||
|
|
||||||
|
return x * x * (3 - 2 * x);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1092,12 +1099,19 @@ Phaser.Math = {
|
||||||
*/
|
*/
|
||||||
smootherstep: function ( x, min, max ) {
|
smootherstep: function ( x, min, max ) {
|
||||||
|
|
||||||
if ( x <= min ) return 0;
|
if (x <= min)
|
||||||
if ( x >= max ) return 1;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
x = ( x - min )/( max - min );
|
if (x >= max)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return x*x*x*(x*(x*6 - 15) + 10);
|
x = (x - min) / (max - min);
|
||||||
|
|
||||||
|
return x * x * x * (x * (x * 6 - 15) + 10);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ Phaser.QuadTree.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* jshint noempty: false */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
* @author Richard Davey <rich@photonstorm.com>
|
||||||
* @copyright 2013 Photon Storm Ltd.
|
* @copyright 2013 Photon Storm Ltd.
|
||||||
|
@ -19,41 +21,41 @@ Phaser.RandomDataGenerator = function (seeds) {
|
||||||
|
|
||||||
if (typeof seeds === "undefined") { 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);
|
this.sow(seeds);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Phaser.RandomDataGenerator.prototype = {
|
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.
|
* Private random helper.
|
||||||
* @method Phaser.RandomDataGenerator#rnd
|
* @method Phaser.RandomDataGenerator#rnd
|
||||||
* @private
|
* @private
|
||||||
* @return {number} Description.
|
* @return {number}
|
||||||
*/
|
*/
|
||||||
rnd: function () {
|
rnd: function () {
|
||||||
|
|
||||||
|
@ -97,11 +99,11 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Internal method that creates a seed hash.
|
||||||
* @method Phaser.RandomDataGenerator#hash
|
* @method Phaser.RandomDataGenerator#hash
|
||||||
* @param {Any} data
|
* @param {Any} data
|
||||||
* @private
|
* @private
|
||||||
* @return {number} Description.
|
* @return {number} hashed value.
|
||||||
*/
|
*/
|
||||||
hash: function (data) {
|
hash: function (data) {
|
||||||
|
|
||||||
|
@ -127,7 +129,7 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random integer between 0 and 2^32.
|
* Returns a random integer between 0 and 2^32.
|
||||||
* @method Phaser.RandomDataGenerator#integer
|
* @method Phaser.RandomDataGenerator#integer
|
||||||
* @return {number}
|
* @return {number} A random integer between 0 and 2^32.
|
||||||
*/
|
*/
|
||||||
integer: function() {
|
integer: function() {
|
||||||
return this.rnd.apply(this) * 0x100000000;// 2^32
|
return this.rnd.apply(this) * 0x100000000;// 2^32
|
||||||
|
@ -136,7 +138,7 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random real number between 0 and 1.
|
* Returns a random real number between 0 and 1.
|
||||||
* @method Phaser.RandomDataGenerator#frac
|
* @method Phaser.RandomDataGenerator#frac
|
||||||
* @return {number}
|
* @return {number} A random real number between 0 and 1.
|
||||||
*/
|
*/
|
||||||
frac: function() {
|
frac: function() {
|
||||||
return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53
|
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.
|
* Returns a random real number between 0 and 2^32.
|
||||||
* @method Phaser.RandomDataGenerator#real
|
* @method Phaser.RandomDataGenerator#real
|
||||||
* @return {number}
|
* @return {number} A random real number between 0 and 2^32.
|
||||||
*/
|
*/
|
||||||
real: function() {
|
real: function() {
|
||||||
return this.integer() + this.frac();
|
return this.integer() + this.frac();
|
||||||
|
@ -154,9 +156,9 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random integer between min and max.
|
* Returns a random integer between min and max.
|
||||||
* @method Phaser.RandomDataGenerator#integerInRange
|
* @method Phaser.RandomDataGenerator#integerInRange
|
||||||
* @param {number} min
|
* @param {number} min - The minimum value in the range.
|
||||||
* @param {number} max
|
* @param {number} max - The maximum value in the range.
|
||||||
* @return {number}
|
* @return {number} A random number between min and max.
|
||||||
*/
|
*/
|
||||||
integerInRange: function (min, max) {
|
integerInRange: function (min, max) {
|
||||||
return Math.floor(this.realInRange(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.
|
* Returns a random real number between min and max.
|
||||||
* @method Phaser.RandomDataGenerator#realInRange
|
* @method Phaser.RandomDataGenerator#realInRange
|
||||||
* @param {number} min
|
* @param {number} min - The minimum value in the range.
|
||||||
* @param {number} max
|
* @param {number} max - The maximum value in the range.
|
||||||
* @return {number}
|
* @return {number} A random number between min and max.
|
||||||
*/
|
*/
|
||||||
realInRange: function (min, max) {
|
realInRange: function (min, max) {
|
||||||
|
|
||||||
|
@ -178,7 +180,7 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random real number between -1 and 1.
|
* Returns a random real number between -1 and 1.
|
||||||
* @method Phaser.RandomDataGenerator#normal
|
* @method Phaser.RandomDataGenerator#normal
|
||||||
* @return {number}
|
* @return {number} A random real number between -1 and 1.
|
||||||
*/
|
*/
|
||||||
normal: function () {
|
normal: function () {
|
||||||
return 1 - 2 * this.frac();
|
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
|
* Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
|
||||||
* @method Phaser.RandomDataGenerator#uuid
|
* @method Phaser.RandomDataGenerator#uuid
|
||||||
* @return {string}
|
* @return {string} A valid RFC4122 version4 ID hex string
|
||||||
*/
|
*/
|
||||||
uuid: function () {
|
uuid: function () {
|
||||||
|
|
||||||
var a, b;
|
var a = '';
|
||||||
|
var b = '';
|
||||||
|
|
||||||
for (
|
for (b = a = ''; a++ < 36; b +=~a % 5 | a * 3&4 ? (a^15 ? 8^this.frac() * (a^20 ? 16 : 4) : 4).toString(16) : '-')
|
||||||
b=a='';
|
{
|
||||||
a++<36;
|
}
|
||||||
b+=~a%5|a*3&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):'-'
|
|
||||||
);
|
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
|
@ -206,8 +207,8 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random member of `array`.
|
* Returns a random member of `array`.
|
||||||
* @method Phaser.RandomDataGenerator#pick
|
* @method Phaser.RandomDataGenerator#pick
|
||||||
* @param {Any} ary
|
* @param {Array} ary - An Array to pick a random member of.
|
||||||
* @return {number}
|
* @return {any} A random member of the array.
|
||||||
*/
|
*/
|
||||||
pick: function (ary) {
|
pick: function (ary) {
|
||||||
return ary[this.integerInRange(0, ary.length)];
|
return ary[this.integerInRange(0, ary.length)];
|
||||||
|
@ -216,8 +217,8 @@ Phaser.RandomDataGenerator.prototype = {
|
||||||
/**
|
/**
|
||||||
* Returns a random member of `array`, favoring the earlier entries.
|
* Returns a random member of `array`, favoring the earlier entries.
|
||||||
* @method Phaser.RandomDataGenerator#weightedPick
|
* @method Phaser.RandomDataGenerator#weightedPick
|
||||||
* @param {Any} ary
|
* @param {Array} ary - An Array to pick a random member of.
|
||||||
* @return {number}
|
* @return {any} A random member of the array.
|
||||||
*/
|
*/
|
||||||
weightedPick: function (ary) {
|
weightedPick: function (ary) {
|
||||||
return ary[~~(Math.pow(this.frac(), 2) * ary.length)];
|
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.
|
* 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
|
* @method Phaser.RandomDataGenerator#timestamp
|
||||||
* @param {number} min
|
* @param {number} min - The minimum value in the range.
|
||||||
* @param {number} max
|
* @param {number} max - The maximum value in the range.
|
||||||
* @return {number}
|
* @return {number} A random timestamp between min and max.
|
||||||
*/
|
*/
|
||||||
timestamp: function (a, b) {
|
timestamp: function (min, max) {
|
||||||
return this.realInRange(a || 946684800000, b || 1577862000000);
|
return this.realInRange(min || 946684800000, max || 1577862000000);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random angle between -180 and 180.
|
* Returns a random angle between -180 and 180.
|
||||||
* @method Phaser.RandomDataGenerator#angle
|
* @method Phaser.RandomDataGenerator#angle
|
||||||
* @return {number}
|
* @return {number} A random number between -180 and 180.
|
||||||
*/
|
*/
|
||||||
angle: function() {
|
angle: function() {
|
||||||
return this.integerInRange(-180, 180);
|
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
|
* @class Phaser.Net
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -43,7 +43,7 @@ Phaser.Net.prototype = {
|
||||||
*
|
*
|
||||||
* @method Phaser.Net#checkDomainName
|
* @method Phaser.Net#checkDomainName
|
||||||
* @param {string} domain
|
* @param {string} domain
|
||||||
* @return {boolean}
|
* @return {boolean} true if the given domain fragment can be found in the window.location.hostname
|
||||||
*/
|
*/
|
||||||
checkDomainName: function (domain) {
|
checkDomainName: function (domain) {
|
||||||
return window.location.hostname.indexOf(domain) !== -1;
|
return window.location.hostname.indexOf(domain) !== -1;
|
||||||
|
@ -65,11 +65,7 @@ Phaser.Net.prototype = {
|
||||||
updateQueryString: function (key, value, redirect, url) {
|
updateQueryString: function (key, value, redirect, url) {
|
||||||
|
|
||||||
if (typeof redirect === "undefined") { redirect = false; }
|
if (typeof redirect === "undefined") { redirect = false; }
|
||||||
if (typeof url === "undefined") { url = ''; }
|
if (typeof url === "undefined" || url === '') { url = window.location.href; }
|
||||||
|
|
||||||
if (url == '') {
|
|
||||||
url = window.location.href;
|
|
||||||
}
|
|
||||||
|
|
||||||
var output = '';
|
var output = '';
|
||||||
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
||||||
|
|
|
@ -15,12 +15,17 @@
|
||||||
Phaser.Particles = function (game) {
|
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 = {};
|
this.emitters = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} ID - Description.
|
* @property {number} ID -
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.ID = 0;
|
this.ID = 0;
|
||||||
|
@ -32,7 +37,7 @@ Phaser.Particles.prototype = {
|
||||||
/**
|
/**
|
||||||
* Adds a new Particle Emitter to the Particle Manager.
|
* Adds a new Particle Emitter to the Particle Manager.
|
||||||
* @method Phaser.Particles#add
|
* @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.
|
* @return {Phaser.Emitter} The emitter that was added.
|
||||||
*/
|
*/
|
||||||
add: function (emitter) {
|
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);
|
particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame);
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
// particle = new this.particleClass(this.game);
|
// particle = new this.particleClass(this.game);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (collide > 0)
|
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.
|
* @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.
|
* @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.
|
* @property {Phaser.Rectangle} _bounds1 - Internal cache var.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._bounds1 = new Phaser.Rectangle;
|
this._bounds1 = new Phaser.Rectangle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Rectangle} _bounds2 - Internal cache var.
|
* @property {Phaser.Rectangle} _bounds2 - Internal cache var.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._bounds2 = new Phaser.Rectangle;
|
this._bounds2 = new Phaser.Rectangle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} _overlap - Internal cache var.
|
* @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)
|
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||||
if (this._overlap != 0)
|
if (this._overlap !== 0)
|
||||||
{
|
{
|
||||||
body1.overlapX = this._overlap;
|
body1.overlapX = this._overlap;
|
||||||
body2.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)
|
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||||
if (this._overlap != 0)
|
if (this._overlap !== 0)
|
||||||
{
|
{
|
||||||
body1.overlapY = this._overlap;
|
body1.overlapY = this._overlap;
|
||||||
body2.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)
|
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||||
if (this._overlap != 0)
|
if (this._overlap !== 0)
|
||||||
{
|
{
|
||||||
if (separate)
|
if (separate)
|
||||||
{
|
{
|
||||||
|
@ -980,7 +980,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
// Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||||
if (this._overlap != 0)
|
if (this._overlap !== 0)
|
||||||
{
|
{
|
||||||
if (separate)
|
if (separate)
|
||||||
{
|
{
|
||||||
|
@ -1133,7 +1133,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||||
velocityFromAngle: function (angle, speed, point) {
|
velocityFromAngle: function (angle, speed, point) {
|
||||||
|
|
||||||
if (typeof speed === 'undefined') { speed = 60; }
|
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));
|
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) {
|
velocityFromRotation: function (rotation, speed, point) {
|
||||||
|
|
||||||
if (typeof speed === 'undefined') { speed = 60; }
|
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));
|
return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
|
||||||
|
|
||||||
|
@ -1171,7 +1171,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||||
accelerationFromRotation: function (rotation, speed, point) {
|
accelerationFromRotation: function (rotation, speed, point) {
|
||||||
|
|
||||||
if (typeof speed === 'undefined') { speed = 60; }
|
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));
|
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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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;
|
this.game = game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the sound.
|
* @property {string} name - Name of the sound.
|
||||||
* @property {string} name
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.name = key;
|
this.name = key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asset key for the sound.
|
* @property {string} key - Asset key for the sound.
|
||||||
* @property {string} key
|
|
||||||
*/
|
*/
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the sound will loop.
|
* @property {boolean} loop - Whether or not the sound will loop.
|
||||||
* @property {boolean} loop
|
|
||||||
*/
|
*/
|
||||||
this.loop = loop;
|
this.loop = loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global audio volume. A value between 0 (silence) and 1 (full volume).
|
* @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume).
|
||||||
* @property {number} _volume
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._volume = volume;
|
this._volume = volume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sound markers, empty by default.
|
* @property {object} markers - The sound markers.
|
||||||
* @property {object} markers
|
|
||||||
*/
|
*/
|
||||||
this.markers = {};
|
this.markers = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to AudioContext instance.
|
* @property {AudioContext} context - Reference to the AudioContext instance.
|
||||||
* @property {AudioContext} context
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.context = null;
|
this.context = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decoded data buffer / Audio tag.
|
* @property {Description} _buffer - Decoded data buffer / Audio tag.
|
||||||
* @property {Description} _buffer
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._buffer = null;
|
this._buffer = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean indicating whether the game is on "mute".
|
* @property {boolean} _muted - Boolean indicating whether the sound is muted or not.
|
||||||
* @property {boolean} _muted
|
|
||||||
* @private
|
* @private
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this._muted = false;
|
this._muted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean indicating whether the sound should start automatically.
|
* @property {boolean} autoplay - Boolean indicating whether the sound should start automatically.
|
||||||
* @property {boolean} autoplay
|
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
this.autoplay = false;
|
this.autoplay = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total duration of the sound, in milliseconds
|
* @property {number} totalDuration - The total duration of the sound, in milliseconds
|
||||||
* @property {number} totalDuration
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.totalDuration = 0;
|
this.totalDuration = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} startTime - The time the Sound starts at (typically 0 unless starting from a marker)
|
||||||
* @property {number} startTime
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.startTime = 0;
|
this.startTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} currentTime - The current time the sound is at.
|
||||||
* @property {number} currentTime
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.currentTime = 0;
|
this.currentTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} duration - The duration of the sound.
|
||||||
* @property {number} duration
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.duration = 0;
|
this.duration = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} stopTime - The time the sound stopped.
|
||||||
* @property {number} stopTime
|
|
||||||
*/
|
*/
|
||||||
this.stopTime = 0;
|
this.stopTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} paused - true if the sound is paused, otherwise false.
|
||||||
* @property {boolean} paused
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} pausedPosition - The position the sound had reached when it was paused.
|
||||||
* @property {number} pausedPosition
|
|
||||||
*/
|
*/
|
||||||
this.pausedPosition = 0;
|
this.pausedPosition = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {number} pausedTime - The game time at which the sound was paused.
|
||||||
* @property {number} pausedTime
|
|
||||||
*/
|
*/
|
||||||
this.pausedTime = 0;
|
this.pausedTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} isPlaying - true if the sound is currently playing, otherwise false.
|
||||||
* @property {boolean} isPlaying
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.isPlaying = false;
|
this.isPlaying = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {string} currentMarker - The string ID of the currently playing marker, if any.
|
||||||
* @property {string} currentMarker
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.currentMarker = '';
|
this.currentMarker = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} pendingPlayback - true if the sound file is pending playback
|
||||||
* @property {boolean} pendingPlayback
|
* @readonly
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.pendingPlayback = false;
|
this.pendingPlayback = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} override - if true when you play this sound it will always start from the beginning.
|
||||||
* @property {boolean} override
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.override = false;
|
this.override = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} usingWebAudio - true if this sound is being played with Web Audio.
|
||||||
* @property {boolean} usingWebAudio
|
* @readonly
|
||||||
*/
|
*/
|
||||||
this.usingWebAudio = this.game.sound.usingWebAudio;
|
this.usingWebAudio = this.game.sound.usingWebAudio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag.
|
||||||
* @property {Description} usingAudioTag
|
|
||||||
*/
|
*/
|
||||||
this.usingAudioTag = this.game.sound.usingAudioTag;
|
this.usingAudioTag = this.game.sound.usingAudioTag;
|
||||||
|
|
||||||
|
@ -217,52 +188,44 @@ Phaser.Sound = function (game, key, volume, loop) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onDecoded - The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files)
|
||||||
* @property {Phaser.Signal} onDecoded
|
|
||||||
*/
|
*/
|
||||||
this.onDecoded = new Phaser.Signal;
|
this.onDecoded = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onPlay - The onPlay event is dispatched each time this sound is played.
|
||||||
* @property {Phaser.Signal} onPlay
|
|
||||||
*/
|
*/
|
||||||
this.onPlay = new Phaser.Signal;
|
this.onPlay = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onPause - The onPause event is dispatched when this sound is paused.
|
||||||
* @property {Phaser.Signal} onPause
|
|
||||||
*/
|
*/
|
||||||
this.onPause = new Phaser.Signal;
|
this.onPause = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onResume - The onResume event is dispatched when this sound is resumed from a paused state.
|
||||||
* @property {Phaser.Signal} onResume
|
|
||||||
*/
|
*/
|
||||||
this.onResume = new Phaser.Signal;
|
this.onResume = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onLoop - The onLoop event is dispatched when this sound loops during playback.
|
||||||
* @property {Phaser.Signal} onLoop
|
|
||||||
*/
|
*/
|
||||||
this.onLoop = new Phaser.Signal;
|
this.onLoop = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onStop - The onStop event is dispatched when this sound stops playback.
|
||||||
* @property {Phaser.Signal} onStop
|
|
||||||
*/
|
*/
|
||||||
this.onStop = new Phaser.Signal;
|
this.onStop = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onMute - The onMouse event is dispatched when this sound is muted.
|
||||||
* @property {Phaser.Signal} onMute
|
|
||||||
*/
|
*/
|
||||||
this.onMute = new Phaser.Signal;
|
this.onMute = new Phaser.Signal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* @property {Phaser.Signal} onMarkerComplete - The onMarkerComplete event is dispatched when a marker within this sound completes playback.
|
||||||
* @property {Phaser.Signal} onMarkerComplete
|
|
||||||
*/
|
*/
|
||||||
this.onMarkerComplete = new Phaser.Signal;
|
this.onMarkerComplete = new Phaser.Signal();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -271,7 +234,7 @@ Phaser.Sound.prototype = {
|
||||||
/**
|
/**
|
||||||
* Called automatically when this sound is unlocked.
|
* Called automatically when this sound is unlocked.
|
||||||
* @method Phaser.Sound#soundHasUnlocked
|
* @method Phaser.Sound#soundHasUnlocked
|
||||||
* @param {string} key - Description.
|
* @param {string} key - The Phaser.Cache key of the sound file to check for decoding.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
soundHasUnlocked: function (key) {
|
soundHasUnlocked: function (key) {
|
||||||
|
@ -377,7 +340,7 @@ Phaser.Sound.prototype = {
|
||||||
// won't work with markers, needs to reset the position
|
// won't work with markers, needs to reset the position
|
||||||
this.onLoop.dispatch(this);
|
this.onLoop.dispatch(this);
|
||||||
|
|
||||||
if (this.currentMarker == '')
|
if (this.currentMarker === '')
|
||||||
{
|
{
|
||||||
//console.log('loop2');
|
//console.log('loop2');
|
||||||
this.currentTime = 0;
|
this.currentTime = 0;
|
||||||
|
@ -524,7 +487,7 @@ Phaser.Sound.prototype = {
|
||||||
this.durationMS = this.totalDuration * 1000;
|
this.durationMS = this.totalDuration * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.loop && marker == '')
|
if (this.loop && marker === '')
|
||||||
{
|
{
|
||||||
this._sound.loop = true;
|
this._sound.loop = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,19 @@ Phaser.SoundManager = function (game) {
|
||||||
this.game = 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
|
* @private
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this._muted = false;
|
this._muted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Description} _unlockSource - Description.
|
* @property {Description} _unlockSource - Internal unlock tracking var.
|
||||||
* @private
|
* @private
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
|
@ -55,37 +55,37 @@ Phaser.SoundManager = function (game) {
|
||||||
this._sounds = [];
|
this._sounds = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Description} context - Description.
|
* @property {AudioContext} context - The AudioContext being used for playback.
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.context = null;
|
this.context = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} usingWebAudio - Description.
|
* @property {boolean} usingWebAudio - true if this sound is being played with Web Audio.
|
||||||
* @default
|
* @readonly
|
||||||
*/
|
*/
|
||||||
this.usingWebAudio = true;
|
this.usingWebAudio = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} usingAudioTag - Description.
|
* @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag.
|
||||||
* @default
|
* @readonly
|
||||||
*/
|
*/
|
||||||
this.usingAudioTag = false;
|
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
|
* @default
|
||||||
*/
|
*/
|
||||||
this.noAudio = false;
|
this.noAudio = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} touchLocked - Description.
|
* @property {boolean} touchLocked - true if the audio system is currently locked awaiting a touch event.
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.touchLocked = false;
|
this.touchLocked = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} channels - Description.
|
* @property {number} channels - The number of audio channels to use in playback.
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.channels = 32;
|
this.channels = 32;
|
||||||
|
|
|
@ -43,7 +43,7 @@ Phaser.Canvas = {
|
||||||
*/
|
*/
|
||||||
getOffset: function (element, point) {
|
getOffset: function (element, point) {
|
||||||
|
|
||||||
point = point || new Phaser.Point;
|
point = point || new Phaser.Point();
|
||||||
|
|
||||||
var box = element.getBoundingClientRect();
|
var box = element.getBoundingClientRect();
|
||||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||||
|
|
|
@ -387,7 +387,7 @@ Phaser.Device.prototype = {
|
||||||
this.mobileSafari = true;
|
this.mobileSafari = true;
|
||||||
} else if (/MSIE (\d+\.\d+);/.test(ua)) {
|
} else if (/MSIE (\d+\.\d+);/.test(ua)) {
|
||||||
this.ie = true;
|
this.ie = true;
|
||||||
this.ieVersion = parseInt(RegExp.$1);
|
this.ieVersion = parseInt(RegExp.$1, 10);
|
||||||
} else if (/Midori/.test(ua)) {
|
} else if (/Midori/.test(ua)) {
|
||||||
this.midori = true;
|
this.midori = true;
|
||||||
} else if (/Opera/.test(ua)) {
|
} else if (/Opera/.test(ua)) {
|
||||||
|
|
|
@ -188,6 +188,11 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||||
*/
|
*/
|
||||||
this.aspectRatio = 0;
|
this.aspectRatio = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {any} event- The native browser events from full screen API changes.
|
||||||
|
*/
|
||||||
|
this.event = null;
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
window.addEventListener('orientationchange', function (event) {
|
window.addEventListener('orientationchange', function (event) {
|
||||||
|
@ -301,6 +306,8 @@ Phaser.StageScaleMode.prototype = {
|
||||||
*/
|
*/
|
||||||
fullScreenChange: function (event) {
|
fullScreenChange: function (event) {
|
||||||
|
|
||||||
|
this.event = event;
|
||||||
|
|
||||||
if (this.isFullScreen)
|
if (this.isFullScreen)
|
||||||
{
|
{
|
||||||
this.game.stage.canvas.style['width'] = '100%';
|
this.game.stage.canvas.style['width'] = '100%';
|
||||||
|
@ -429,6 +436,8 @@ Phaser.StageScaleMode.prototype = {
|
||||||
*/
|
*/
|
||||||
checkOrientation: function (event) {
|
checkOrientation: function (event) {
|
||||||
|
|
||||||
|
this.event = event;
|
||||||
|
|
||||||
this.orientation = window['orientation'];
|
this.orientation = window['orientation'];
|
||||||
|
|
||||||
if (this.isLandscape)
|
if (this.isLandscape)
|
||||||
|
@ -454,6 +463,8 @@ Phaser.StageScaleMode.prototype = {
|
||||||
*/
|
*/
|
||||||
checkResize: function (event) {
|
checkResize: function (event) {
|
||||||
|
|
||||||
|
this.event = event;
|
||||||
|
|
||||||
if (window.outerWidth > window.outerHeight)
|
if (window.outerWidth > window.outerHeight)
|
||||||
{
|
{
|
||||||
this.orientation = 90;
|
this.orientation = 90;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
* @module Phaser.Tile
|
* @module Phaser.Tile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new <code>Tile</code>.
|
* Create a new <code>Tile</code>.
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,7 +8,7 @@ Phaser.Tilemap = function (game, key) {
|
||||||
/**
|
/**
|
||||||
* @property {array} layers - Description.
|
* @property {array} layers - Description.
|
||||||
*/
|
*/
|
||||||
this.layers;
|
this.layers = null;
|
||||||
|
|
||||||
if (typeof key === 'string')
|
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)
|
if (value.index === this._tempA)
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,9 +256,9 @@ Phaser.TilemapLayer.prototype._fixX = function(x) {
|
||||||
return 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;
|
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;
|
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;
|
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++)
|
for (var c = 0; c < column.length; c++)
|
||||||
{
|
{
|
||||||
output[i][c] = parseInt(column[c]);
|
output[i][c] = parseInt(column[c], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width === 0)
|
if (width === 0)
|
||||||
|
@ -145,7 +145,7 @@ Phaser.TilemapParser = {
|
||||||
indexes: [],
|
indexes: [],
|
||||||
|
|
||||||
tileMargin: json.tilesets[0].margin,
|
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);
|
this.tiles[index].setCollision(left, right, up, down);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,124 +20,91 @@ Phaser.Time = function (game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time at which the Game instance started.
|
* @property {number} _started - The time at which the Game instance started.
|
||||||
* @property {number} _started
|
|
||||||
* @private
|
* @private
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this._started = 0;
|
this._started = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time (in ms) that the last second counter ticked over.
|
* @property {number} _timeLastSecond - The time (in ms) that the last second counter ticked over.
|
||||||
* @property {number} _timeLastSecond
|
|
||||||
* @private
|
* @private
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this._timeLastSecond = 0;
|
this._timeLastSecond = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time the game started being paused.
|
* @property {number} _pauseStarted - The time the game started being paused.
|
||||||
* @property {number} _pauseStarted
|
|
||||||
* @private
|
* @private
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this._pauseStarted = 0;
|
this._pauseStarted = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The elapsed time calculated for the physics motion updates.
|
* @property {number} physicsElapsed - The elapsed time calculated for the physics motion updates.
|
||||||
* @property {number} physicsElapsed
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.physicsElapsed = 0;
|
this.physicsElapsed = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game time counter.
|
* @property {number} time - Game time counter.
|
||||||
* @property {number} time
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.time = 0;
|
this.time = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records how long the game has been paused for. Is reset each time the game pauses.
|
* @property {number} pausedTime - Records how long the game has been paused for. Is reset each time the game pauses.
|
||||||
* @property {number} pausedTime
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.pausedTime = 0;
|
this.pausedTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time right now.
|
* @property {number} now - The time right now.
|
||||||
* @property {number} now
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.now = 0;
|
this.now = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elapsed time since the last frame.
|
* @property {number} elapsed - Elapsed time since the last frame.
|
||||||
* @property {number} elapsed
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.elapsed = 0;
|
this.elapsed = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frames per second.
|
* @property {number} fps - Frames per second.
|
||||||
* @property {number} fps
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.fps = 0;
|
this.fps = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lowest rate the fps has dropped to.
|
* @property {number} fpsMin - The lowest rate the fps has dropped to.
|
||||||
* @property {number} fpsMin
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.fpsMin = 1000;
|
this.fpsMin = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The highest rate the fps has reached (usually no higher than 60fps).
|
* @property {number} fpsMax - The highest rate the fps has reached (usually no higher than 60fps).
|
||||||
* @property {number} fpsMax
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.fpsMax = 0;
|
this.fpsMax = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum amount of time the game has taken between two frames.
|
* @property {number} msMin - The minimum amount of time the game has taken between two frames.
|
||||||
* @property {number} msMin
|
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
this.msMin = 1000;
|
this.msMin = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum amount of time the game has taken between two frames.
|
* @property {number} msMax - The maximum amount of time the game has taken between two frames.
|
||||||
* @property {number} msMax
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.msMax = 0;
|
this.msMax = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of frames record in the last second.
|
* @property {number} frames - The number of frames record in the last second.
|
||||||
* @property {number} frames
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.frames = 0;
|
this.frames = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records how long the game was paused for in miliseconds.
|
* @property {number} pauseDuration - Records how long the game was paused for in miliseconds.
|
||||||
* @property {number} pauseDuration
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.pauseDuration = 0;
|
this.pauseDuration = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value that setTimeout needs to work out when to next update
|
* @property {number} timeToCall - The value that setTimeout needs to work out when to next update
|
||||||
* @property {number} timeToCall
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.timeToCall = 0;
|
this.timeToCall = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal value used by timeToCall as part of the setTimeout loop
|
* @property {number} lastTime - Internal value used by timeToCall as part of the setTimeout loop
|
||||||
* @property {number} lastTime
|
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this.lastTime = 0;
|
this.lastTime = 0;
|
||||||
|
|
||||||
|
@ -146,9 +113,8 @@ Phaser.Time = function (game) {
|
||||||
this.game.onResume.add(this.gameResumed, this);
|
this.game.onResume.add(this.gameResumed, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal value used to recover from the game pause state.
|
* @property {boolean} _justResumed - Internal value used to recover from the game pause state.
|
||||||
* @property {boolean} _justResumed
|
* @private
|
||||||
* @default
|
|
||||||
*/
|
*/
|
||||||
this._justResumed = false;
|
this._justResumed = false;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* jshint curly: false */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
* @author Richard Davey <rich@photonstorm.com>
|
||||||
* @copyright 2013 Photon Storm Ltd.
|
* @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.
|
* Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
|
||||||
*
|
*
|
||||||
* @method Phaser.Tween#start
|
* @method Phaser.Tween#start
|
||||||
* @param {number} time - Description.
|
|
||||||
* @return {Phaser.Tween} Itself.
|
* @return {Phaser.Tween} Itself.
|
||||||
*/
|
*/
|
||||||
start: function ( time ) {
|
start: function () {
|
||||||
|
|
||||||
if (this.game === null || this._object === null) {
|
if (this.game === null || this._object === null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -126,7 +126,10 @@ Phaser.TweenManager.prototype = {
|
||||||
*/
|
*/
|
||||||
update: function () {
|
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 i = 0;
|
||||||
var numTweens = this._tweens.length;
|
var numTweens = this._tweens.length;
|
||||||
|
@ -182,7 +185,7 @@ Phaser.TweenManager.prototype = {
|
||||||
|
|
||||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||||
this._tweens[i].pause();
|
this._tweens[i].pause();
|
||||||
};
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -195,7 +198,7 @@ Phaser.TweenManager.prototype = {
|
||||||
|
|
||||||
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
for (var i = this._tweens.length - 1; i >= 0; i--) {
|
||||||
this._tweens[i].resume();
|
this._tweens[i].resume();
|
||||||
};
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* jshint supernew: true */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Richard Davey <rich@photonstorm.com>
|
* @author Richard Davey <rich@photonstorm.com>
|
||||||
* @copyright 2013 Photon Storm Ltd.
|
* @copyright 2013 Photon Storm Ltd.
|
||||||
|
@ -47,6 +49,8 @@ Phaser.Utils = {
|
||||||
if (typeof(pad) == "undefined") { var pad = ' '; }
|
if (typeof(pad) == "undefined") { var pad = ' '; }
|
||||||
if (typeof(dir) == "undefined") { var dir = 3; }
|
if (typeof(dir) == "undefined") { var dir = 3; }
|
||||||
|
|
||||||
|
var padlen = 0;
|
||||||
|
|
||||||
if (len + 1 >= str.length)
|
if (len + 1 >= str.length)
|
||||||
{
|
{
|
||||||
switch (dir)
|
switch (dir)
|
||||||
|
@ -200,7 +204,7 @@ Phaser.Utils = {
|
||||||
if (consoleDisabled) {
|
if (consoleDisabled) {
|
||||||
window.console = undefined;
|
window.console = undefined;
|
||||||
}
|
}
|
||||||
if (window.console == undefined) {
|
if (window.console === undefined) {
|
||||||
window.console = {
|
window.console = {
|
||||||
debug: function() {
|
debug: function() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -244,12 +248,19 @@ function HEXtoRGB(hex) {
|
||||||
* A polyfill for Function.prototype.bind
|
* A polyfill for Function.prototype.bind
|
||||||
*/
|
*/
|
||||||
if (typeof Function.prototype.bind != 'function') {
|
if (typeof Function.prototype.bind != 'function') {
|
||||||
|
|
||||||
Function.prototype.bind = (function () {
|
Function.prototype.bind = (function () {
|
||||||
|
|
||||||
var slice = Array.prototype.slice;
|
var slice = Array.prototype.slice;
|
||||||
|
|
||||||
return function (thisArg) {
|
return function (thisArg) {
|
||||||
|
|
||||||
var target = this, boundArgs = slice.call(arguments, 1);
|
var target = this, boundArgs = slice.call(arguments, 1);
|
||||||
|
|
||||||
if (typeof target != 'function') throw new TypeError();
|
if (typeof target != 'function')
|
||||||
|
{
|
||||||
|
throw new TypeError();
|
||||||
|
}
|
||||||
|
|
||||||
function bound() {
|
function bound() {
|
||||||
var args = boundArgs.concat(slice.call(arguments));
|
var args = boundArgs.concat(slice.call(arguments));
|
||||||
|
@ -258,11 +269,14 @@ if (typeof Function.prototype.bind != 'function') {
|
||||||
|
|
||||||
bound.prototype = (function F(proto) {
|
bound.prototype = (function F(proto) {
|
||||||
proto && (F.prototype = proto);
|
proto && (F.prototype = proto);
|
||||||
if (!(this instanceof F)) return new F;
|
|
||||||
|
if (!(this instanceof F))
|
||||||
|
{
|
||||||
|
return new F;
|
||||||
|
}
|
||||||
})(target.prototype);
|
})(target.prototype);
|
||||||
|
|
||||||
return bound;
|
return bound;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue