mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
2.4.9 build test.
This commit is contained in:
parent
68c29470cf
commit
c4cded108f
18 changed files with 1928 additions and 441 deletions
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:17:39
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:38:57
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -3676,9 +3676,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
return;
|
||||
}
|
||||
|
||||
// update the scene graph
|
||||
stage.updateTransform();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// -- Does this need to be set every frame? -- //
|
||||
|
@ -6659,8 +6656,6 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
|
|||
*/
|
||||
PIXI.CanvasRenderer.prototype.render = function (stage) {
|
||||
|
||||
stage.updateTransform();
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
this.context.globalAlpha = 1;
|
||||
|
@ -10977,7 +10972,7 @@ PIXI.Ellipse = Phaser.Ellipse;
|
|||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
|
@ -11014,7 +11009,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
|
@ -11034,7 +11029,7 @@ Phaser.Line.prototype = {
|
|||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
|
@ -11056,7 +11051,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromAngle
|
||||
* @param {number} x - The x coordinate of the start of the line.
|
||||
* @param {number} y - The y coordinate of the start of the line.
|
||||
|
@ -11075,12 +11070,12 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
* If you wish to rotate around a different point see Line.rotateAround.
|
||||
*
|
||||
*
|
||||
* If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
|
@ -11100,9 +11095,9 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place around the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotateAround
|
||||
* @param {number} x - The x coordinate to offset the rotation from.
|
||||
* @param {number} y - The y coordinate to offset the rotation from.
|
||||
|
@ -11152,7 +11147,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#midPoint
|
||||
* @param {Phaser.Point} [out] - A Phaser.Point object into which the result will be populated. If not given a new Point object is created.
|
||||
* @return {Phaser.Point} A Phaser.Point object with the x and y values set to the center of the line segment.
|
||||
|
@ -11170,10 +11165,10 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Centers this Line on the given coordinates.
|
||||
*
|
||||
*
|
||||
* The line is centered by positioning the start and end points so that the lines midpoint matches
|
||||
* the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#centerOn
|
||||
* @param {number} x - The x position to center the line on.
|
||||
* @param {number} y - The y position to center the line on.
|
||||
|
@ -11194,7 +11189,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -11208,7 +11203,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -11227,7 +11222,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Picks a random point from anywhere on the Line segment and returns it.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#random
|
||||
* @param {Phaser.Point|object} [out] - A Phaser.Point, or any object with public x/y properties, that the values will be set in.
|
||||
* If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object.
|
||||
|
@ -11598,6 +11593,98 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
||||
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
|
||||
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
|
||||
*/
|
||||
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||
|
||||
// Quick bail out of the Line and Rect bounds don't intersect
|
||||
if (!Phaser.Rectangle.intersects(line, rect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var x1 = line.start.x;
|
||||
var y1 = line.start.y;
|
||||
|
||||
var x2 = line.end.x;
|
||||
var y2 = line.end.y;
|
||||
|
||||
var bx1 = rect.x;
|
||||
var by1 = rect.y;
|
||||
var bx2 = rect.right;
|
||||
var by2 = rect.bottom;
|
||||
|
||||
var t = 0;
|
||||
|
||||
// If the start or end of the line is inside the rect then we assume
|
||||
// collision, as rects are solid for our use-case.
|
||||
|
||||
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
||||
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x1 < bx1 && x2 >= bx1)
|
||||
{
|
||||
// Left edge
|
||||
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
||||
|
||||
if (t > by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (x1 > bx2 && x2 <= bx2)
|
||||
{
|
||||
// Right edge
|
||||
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
||||
|
||||
if (t >= by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (y1 < by1 && y2 >= by1)
|
||||
{
|
||||
// Top edge
|
||||
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (y1 > by2 && y2 <= by2)
|
||||
{
|
||||
// Bottom edge
|
||||
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
|
@ -14929,7 +15016,8 @@ Phaser.Camera.prototype = {
|
|||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
this._targetPosition.copyFrom(this.target.world);
|
||||
this._targetPosition.x = this.view.x + this.target.worldPosition.x;
|
||||
this._targetPosition.y = this.view.y + this.target.worldPosition.y;
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
|
@ -15336,6 +15424,11 @@ Phaser.State = function () {
|
|||
*/
|
||||
this.stage = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.StateManager} stage - A reference to the State Manager, which controls state changes.
|
||||
*/
|
||||
this.state = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Time} time - A reference to the game clock and timed events system.
|
||||
*/
|
||||
|
@ -17826,33 +17919,16 @@ Phaser.Stage.prototype.update = function () {
|
|||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
this.updateTransform();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.game.world.camera.update();
|
||||
|
||||
};
|
||||
|
||||
|
@ -18081,7 +18157,7 @@ Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
|||
* In addition, Groups provides support for fast pooling and object recycling.
|
||||
*
|
||||
* Groups are also display objects and can be nested as children within other Groups.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Group
|
||||
* @extends PIXI.DisplayObjectContainer
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -18175,13 +18251,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
this.ignoreDestroy = false;
|
||||
|
||||
/**
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* called on the next logic update.
|
||||
* You can set it directly to flag the Group to be destroyed on its next update.
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
* or a callback of one of its children.
|
||||
*
|
||||
*
|
||||
* @property {boolean} pendingDestroy
|
||||
*/
|
||||
this.pendingDestroy = false;
|
||||
|
@ -18232,7 +18308,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
|
||||
/**
|
||||
* If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.
|
||||
*
|
||||
*
|
||||
* It should be set to one of the Phaser.Physics.Arcade sort direction constants:
|
||||
*
|
||||
* Phaser.Physics.Arcade.SORT_NONE
|
||||
|
@ -20043,6 +20119,80 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the closest child to given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object) {
|
||||
|
||||
var distance = Number.MAX_VALUE;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the child furthest away from the given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getFarthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFarthestFrom = function (object) {
|
||||
|
||||
var distance = 0;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of living children in this group.
|
||||
*
|
||||
|
@ -28151,6 +28301,11 @@ Phaser.Gamepad.prototype = {
|
|||
*/
|
||||
_pollGamepads: function () {
|
||||
|
||||
if (!this._active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator['getGamepads'])
|
||||
{
|
||||
var rawGamepads = navigator.getGamepads();
|
||||
|
@ -28190,6 +28345,11 @@ Phaser.Gamepad.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
for (var g = 0; g < this._gamepads.length; g++)
|
||||
{
|
||||
this._gamepads[g]._rawPad = this._rawPads[g];
|
||||
}
|
||||
|
||||
if (gamepadsChanged)
|
||||
{
|
||||
var validConnections = { rawIndices: {}, padIndices: {} };
|
||||
|
@ -41163,12 +41323,23 @@ Phaser.Text.prototype.updateText = function () {
|
|||
drawnLines = this.style.maxLines;
|
||||
}
|
||||
|
||||
this._charCount = 0;
|
||||
|
||||
for (var i = 0; i < drawnLines; i++)
|
||||
{
|
||||
if (tabs === 0)
|
||||
{
|
||||
// Simple layout (no tabs)
|
||||
var lineWidth = this.context.measureText(lines[i]).width + this.style.strokeThickness + this.padding.x;
|
||||
var lineWidth = this.style.strokeThickness + this.padding.x;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(lines[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += this.context.measureText(lines[i]).width;
|
||||
}
|
||||
|
||||
// Adjust for wrapped text
|
||||
if (this.style.wordWrap)
|
||||
|
@ -41188,7 +41359,16 @@ Phaser.Text.prototype.updateText = function () {
|
|||
|
||||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
var section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
var section = 0;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
section = this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
|
@ -41203,7 +41383,14 @@ Phaser.Text.prototype.updateText = function () {
|
|||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
// How far to the next tab?
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
var diff = this.game.math.snapToCeil(lineWidth, tabs) - lineWidth;
|
||||
|
||||
|
@ -41421,6 +41608,67 @@ Phaser.Text.prototype.updateShadow = function (state) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Measures a line of text character by character taking into the account the specified character styles.
|
||||
*
|
||||
* @method Phaser.Text#measureLine
|
||||
* @private
|
||||
* @param {string} line - The line of text to measure.
|
||||
* @return {integer} length of the line.
|
||||
*/
|
||||
Phaser.Text.prototype.measureLine = function (line) {
|
||||
|
||||
var lineLength = 0;
|
||||
|
||||
for (var i = 0; i < line.length; i++)
|
||||
{
|
||||
var letter = line[i];
|
||||
|
||||
if (this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
var components = this.fontToComponents(this.context.font);
|
||||
|
||||
if (this.fontStyles[this._charCount])
|
||||
{
|
||||
components.fontStyle = this.fontStyles[this._charCount];
|
||||
}
|
||||
|
||||
if (this.fontWeights[this._charCount])
|
||||
{
|
||||
components.fontWeight = this.fontWeights[this._charCount];
|
||||
}
|
||||
|
||||
this.context.font = this.componentsToFont(components);
|
||||
}
|
||||
|
||||
if (this.style.stroke && this.style.strokeThickness)
|
||||
{
|
||||
if (this.strokeColors[this._charCount])
|
||||
{
|
||||
this.context.strokeStyle = this.strokeColors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowStroke);
|
||||
}
|
||||
|
||||
if (this.style.fill)
|
||||
{
|
||||
if (this.colors[this._charCount])
|
||||
{
|
||||
this.context.fillStyle = this.colors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowFill);
|
||||
}
|
||||
|
||||
lineLength += this.context.measureText(letter).width;
|
||||
|
||||
this._charCount++;
|
||||
}
|
||||
|
||||
return Math.ceil(lineLength);
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable.
|
||||
*
|
||||
|
@ -43206,6 +43454,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
var x = 0;
|
||||
var w = 0;
|
||||
var lastSpace = -1;
|
||||
var wrappedWidth = 0;
|
||||
var prevCharCode = null;
|
||||
var maxWidth = (this._maxWidth > 0) ? this._maxWidth : null;
|
||||
var chars = [];
|
||||
|
@ -43237,9 +43486,12 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
// Adjust for kerning from previous character to this one
|
||||
var kerning = (prevCharCode && charData.kerning[prevCharCode]) ? charData.kerning[prevCharCode] : 0;
|
||||
|
||||
// Record the last space in the string
|
||||
lastSpace = /(\s)/.test(text.charAt(i)) ? i : lastSpace;
|
||||
|
||||
// Record the last space in the string and the current width
|
||||
if (/(\s)/.test(text.charAt(i))) {
|
||||
lastSpace = i;
|
||||
wrappedWidth = w;
|
||||
}
|
||||
|
||||
// What will the line width be if we add this character to it?
|
||||
c = (kerning + charData.texture.width + charData.xOffset) * scale;
|
||||
|
||||
|
@ -43247,7 +43499,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
if (maxWidth && ((w + c) >= maxWidth) && lastSpace > -1)
|
||||
{
|
||||
// The last space was at "lastSpace" which was "i - lastSpace" characters ago
|
||||
return { width: w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
return { width: wrappedWidth || w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -52970,7 +53222,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
*
|
||||
*
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
|
@ -53094,10 +53346,10 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
this.onStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`.
|
||||
* Note that the event is only dispatched with the current frame. In a low-FPS environment Animations
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* receive a perfectly sequential set of frames from this event.
|
||||
* @property {Phaser.Signal|null} onUpdate
|
||||
* @default
|
||||
|
@ -53114,6 +53366,12 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
*/
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} isReversed - Indicates if the animation will play backwards.
|
||||
* @default
|
||||
*/
|
||||
this.isReversed = false;
|
||||
|
||||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
@ -53159,7 +53417,7 @@ Phaser.Animation.prototype = {
|
|||
this._timeLastFrame = this.game.time.time;
|
||||
this._timeNextFrame = this.game.time.time + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this._frameIndex = this.isReversed ? this._frames.length - 1 : 0;
|
||||
this.updateCurrentFrame(false, true);
|
||||
|
||||
this._parent.events.onAnimationStart$dispatch(this._parent, this);
|
||||
|
@ -53201,6 +53459,32 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction
|
||||
*
|
||||
* @method Phaser.Animation#reverse
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverse: function () {
|
||||
this.reversed = !this.reversed;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction for the current/next animation only
|
||||
* Once the onComplete event is called this method will be called again and revert
|
||||
* the reversed state.
|
||||
*
|
||||
* @method Phaser.Animation#reverseOnce
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverseOnce: function () {
|
||||
this.onComplete.addOnce(this.reverse.bind(this));
|
||||
|
||||
return this.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animations playback to a given frame with the given ID.
|
||||
*
|
||||
|
@ -53349,14 +53633,23 @@ Phaser.Animation.prototype = {
|
|||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
if (this.isReversed){
|
||||
this._frameIndex -= this._frameSkip;
|
||||
}else{
|
||||
this._frameIndex += this._frameSkip;
|
||||
}
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
if (!this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1)
|
||||
{
|
||||
if (this.loop)
|
||||
{
|
||||
// Update current state before event callback
|
||||
this._frameIndex %= this._frames.length;
|
||||
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
||||
|
||||
if (this.isReversed){
|
||||
this._frameIndex = this._frames.length - 1 - this._frameIndex;
|
||||
}
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
// Instead of calling updateCurrentFrame we do it here instead
|
||||
|
@ -53418,7 +53711,7 @@ Phaser.Animation.prototype = {
|
|||
// The animation is already destroyed, probably from a callback
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Previous index
|
||||
var idx = this.currentFrame.index;
|
||||
|
||||
|
@ -53618,6 +53911,26 @@ Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#reversed
|
||||
* @property {boolean} reversed - Gets and sets the isReversed state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'reversed', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isReversed;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isReversed = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
|
@ -60340,12 +60653,13 @@ Phaser.Sound.prototype = {
|
|||
* @method Phaser.Sound#addMarker
|
||||
* @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc.
|
||||
* @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [duration=1] - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume).
|
||||
* @param {boolean} [loop=false] - Sets if the sound will loop or not.
|
||||
*/
|
||||
addMarker: function (name, start, duration, volume, loop) {
|
||||
|
||||
if (duration === undefined || duration === null) { duration = 1; }
|
||||
if (volume === undefined || volume === null) { volume = 1; }
|
||||
if (loop === undefined) { loop = false; }
|
||||
|
||||
|
@ -69865,6 +70179,11 @@ Phaser.Physics.Arcade.prototype = {
|
|||
*/
|
||||
intersects: function (body1, body2) {
|
||||
|
||||
if (body1 === body2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rect vs. Rect
|
||||
if (body1.right <= body2.position.x)
|
||||
{
|
||||
|
@ -71306,11 +71625,6 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
setSize: function (width, height, offsetX, offsetY) {
|
||||
|
||||
if (this.isCircle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetX === undefined) { offsetX = this.offset.x; }
|
||||
if (offsetY === undefined) { offsetY = this.offset.y; }
|
||||
|
||||
|
@ -71371,7 +71685,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
hitTest: function (x, y) {
|
||||
|
||||
return (this.isCircle) ? Phaser.Circle.contains(this, x, y) : Phaser.Rectangle.contains(this, x, y);
|
||||
return Phaser.Rectangle.contains(this, x, y);
|
||||
|
||||
},
|
||||
|
||||
|
@ -78043,6 +78357,9 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
|
|||
* Small screen devices, especially iPod and iPhone will launch the video in its own native video player,
|
||||
* outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation.
|
||||
*
|
||||
* Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends)
|
||||
* then you need to add your own event listener
|
||||
*
|
||||
* @class Phaser.Video
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -78105,7 +78422,7 @@ Phaser.Video = function (game, key, url) {
|
|||
this.onChangeSource = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. Videos set to loop will never dispatch this signal.
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal.
|
||||
*/
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
|
@ -78676,6 +78993,7 @@ Phaser.Video.prototype = {
|
|||
this._endCallback = this.complete.bind(this);
|
||||
|
||||
this.video.addEventListener('ended', this._endCallback, true);
|
||||
this.video.addEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
|
||||
if (loop)
|
||||
{
|
||||
|
@ -78797,6 +79115,7 @@ Phaser.Video.prototype = {
|
|||
else
|
||||
{
|
||||
this.video.removeEventListener('ended', this._endCallback, true);
|
||||
this.video.removeEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
this.video.removeEventListener('playing', this._playCallback, true);
|
||||
|
||||
if (this.touchLocked)
|
||||
|
|
File diff suppressed because one or more lines are too long
36
build/custom/phaser-arcade-physics.min.js
vendored
36
build/custom/phaser-arcade-physics.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:17:56
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:39:14
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -3676,9 +3676,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
return;
|
||||
}
|
||||
|
||||
// update the scene graph
|
||||
stage.updateTransform();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// -- Does this need to be set every frame? -- //
|
||||
|
@ -6659,8 +6656,6 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
|
|||
*/
|
||||
PIXI.CanvasRenderer.prototype.render = function (stage) {
|
||||
|
||||
stage.updateTransform();
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
this.context.globalAlpha = 1;
|
||||
|
@ -9777,7 +9772,7 @@ PIXI.Ellipse = Phaser.Ellipse;
|
|||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
|
@ -9814,7 +9809,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
|
@ -9834,7 +9829,7 @@ Phaser.Line.prototype = {
|
|||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
|
@ -9856,7 +9851,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromAngle
|
||||
* @param {number} x - The x coordinate of the start of the line.
|
||||
* @param {number} y - The y coordinate of the start of the line.
|
||||
|
@ -9875,12 +9870,12 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
* If you wish to rotate around a different point see Line.rotateAround.
|
||||
*
|
||||
*
|
||||
* If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
|
@ -9900,9 +9895,9 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place around the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotateAround
|
||||
* @param {number} x - The x coordinate to offset the rotation from.
|
||||
* @param {number} y - The y coordinate to offset the rotation from.
|
||||
|
@ -9952,7 +9947,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#midPoint
|
||||
* @param {Phaser.Point} [out] - A Phaser.Point object into which the result will be populated. If not given a new Point object is created.
|
||||
* @return {Phaser.Point} A Phaser.Point object with the x and y values set to the center of the line segment.
|
||||
|
@ -9970,10 +9965,10 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Centers this Line on the given coordinates.
|
||||
*
|
||||
*
|
||||
* The line is centered by positioning the start and end points so that the lines midpoint matches
|
||||
* the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#centerOn
|
||||
* @param {number} x - The x position to center the line on.
|
||||
* @param {number} y - The y position to center the line on.
|
||||
|
@ -9994,7 +9989,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -10008,7 +10003,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -10027,7 +10022,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Picks a random point from anywhere on the Line segment and returns it.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#random
|
||||
* @param {Phaser.Point|object} [out] - A Phaser.Point, or any object with public x/y properties, that the values will be set in.
|
||||
* If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object.
|
||||
|
@ -10398,6 +10393,98 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
||||
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
|
||||
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
|
||||
*/
|
||||
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||
|
||||
// Quick bail out of the Line and Rect bounds don't intersect
|
||||
if (!Phaser.Rectangle.intersects(line, rect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var x1 = line.start.x;
|
||||
var y1 = line.start.y;
|
||||
|
||||
var x2 = line.end.x;
|
||||
var y2 = line.end.y;
|
||||
|
||||
var bx1 = rect.x;
|
||||
var by1 = rect.y;
|
||||
var bx2 = rect.right;
|
||||
var by2 = rect.bottom;
|
||||
|
||||
var t = 0;
|
||||
|
||||
// If the start or end of the line is inside the rect then we assume
|
||||
// collision, as rects are solid for our use-case.
|
||||
|
||||
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
||||
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x1 < bx1 && x2 >= bx1)
|
||||
{
|
||||
// Left edge
|
||||
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
||||
|
||||
if (t > by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (x1 > bx2 && x2 <= bx2)
|
||||
{
|
||||
// Right edge
|
||||
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
||||
|
||||
if (t >= by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (y1 < by1 && y2 >= by1)
|
||||
{
|
||||
// Top edge
|
||||
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (y1 > by2 && y2 <= by2)
|
||||
{
|
||||
// Bottom edge
|
||||
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
|
@ -13729,7 +13816,8 @@ Phaser.Camera.prototype = {
|
|||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
this._targetPosition.copyFrom(this.target.world);
|
||||
this._targetPosition.x = this.view.x + this.target.worldPosition.x;
|
||||
this._targetPosition.y = this.view.y + this.target.worldPosition.y;
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
|
@ -14136,6 +14224,11 @@ Phaser.State = function () {
|
|||
*/
|
||||
this.stage = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.StateManager} stage - A reference to the State Manager, which controls state changes.
|
||||
*/
|
||||
this.state = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Time} time - A reference to the game clock and timed events system.
|
||||
*/
|
||||
|
@ -16626,33 +16719,16 @@ Phaser.Stage.prototype.update = function () {
|
|||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
this.updateTransform();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.game.world.camera.update();
|
||||
|
||||
};
|
||||
|
||||
|
@ -16881,7 +16957,7 @@ Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
|||
* In addition, Groups provides support for fast pooling and object recycling.
|
||||
*
|
||||
* Groups are also display objects and can be nested as children within other Groups.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Group
|
||||
* @extends PIXI.DisplayObjectContainer
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -16975,13 +17051,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
this.ignoreDestroy = false;
|
||||
|
||||
/**
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* called on the next logic update.
|
||||
* You can set it directly to flag the Group to be destroyed on its next update.
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
* or a callback of one of its children.
|
||||
*
|
||||
*
|
||||
* @property {boolean} pendingDestroy
|
||||
*/
|
||||
this.pendingDestroy = false;
|
||||
|
@ -17032,7 +17108,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
|
||||
/**
|
||||
* If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.
|
||||
*
|
||||
*
|
||||
* It should be set to one of the Phaser.Physics.Arcade sort direction constants:
|
||||
*
|
||||
* Phaser.Physics.Arcade.SORT_NONE
|
||||
|
@ -18843,6 +18919,80 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the closest child to given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object) {
|
||||
|
||||
var distance = Number.MAX_VALUE;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the child furthest away from the given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getFarthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFarthestFrom = function (object) {
|
||||
|
||||
var distance = 0;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of living children in this group.
|
||||
*
|
||||
|
@ -36863,7 +37013,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
*
|
||||
*
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
|
@ -36987,10 +37137,10 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
this.onStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`.
|
||||
* Note that the event is only dispatched with the current frame. In a low-FPS environment Animations
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* receive a perfectly sequential set of frames from this event.
|
||||
* @property {Phaser.Signal|null} onUpdate
|
||||
* @default
|
||||
|
@ -37007,6 +37157,12 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
*/
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} isReversed - Indicates if the animation will play backwards.
|
||||
* @default
|
||||
*/
|
||||
this.isReversed = false;
|
||||
|
||||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
@ -37052,7 +37208,7 @@ Phaser.Animation.prototype = {
|
|||
this._timeLastFrame = this.game.time.time;
|
||||
this._timeNextFrame = this.game.time.time + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this._frameIndex = this.isReversed ? this._frames.length - 1 : 0;
|
||||
this.updateCurrentFrame(false, true);
|
||||
|
||||
this._parent.events.onAnimationStart$dispatch(this._parent, this);
|
||||
|
@ -37094,6 +37250,32 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction
|
||||
*
|
||||
* @method Phaser.Animation#reverse
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverse: function () {
|
||||
this.reversed = !this.reversed;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction for the current/next animation only
|
||||
* Once the onComplete event is called this method will be called again and revert
|
||||
* the reversed state.
|
||||
*
|
||||
* @method Phaser.Animation#reverseOnce
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverseOnce: function () {
|
||||
this.onComplete.addOnce(this.reverse.bind(this));
|
||||
|
||||
return this.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animations playback to a given frame with the given ID.
|
||||
*
|
||||
|
@ -37242,14 +37424,23 @@ Phaser.Animation.prototype = {
|
|||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
if (this.isReversed){
|
||||
this._frameIndex -= this._frameSkip;
|
||||
}else{
|
||||
this._frameIndex += this._frameSkip;
|
||||
}
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
if (!this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1)
|
||||
{
|
||||
if (this.loop)
|
||||
{
|
||||
// Update current state before event callback
|
||||
this._frameIndex %= this._frames.length;
|
||||
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
||||
|
||||
if (this.isReversed){
|
||||
this._frameIndex = this._frames.length - 1 - this._frameIndex;
|
||||
}
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
// Instead of calling updateCurrentFrame we do it here instead
|
||||
|
@ -37311,7 +37502,7 @@ Phaser.Animation.prototype = {
|
|||
// The animation is already destroyed, probably from a callback
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Previous index
|
||||
var idx = this.currentFrame.index;
|
||||
|
||||
|
@ -37511,6 +37702,26 @@ Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#reversed
|
||||
* @property {boolean} reversed - Gets and sets the isReversed state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'reversed', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isReversed;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isReversed = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
|
|
File diff suppressed because one or more lines are too long
22
build/custom/phaser-minimum.min.js
vendored
22
build/custom/phaser-minimum.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:17:48
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:39:06
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -3676,9 +3676,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
return;
|
||||
}
|
||||
|
||||
// update the scene graph
|
||||
stage.updateTransform();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// -- Does this need to be set every frame? -- //
|
||||
|
@ -6659,8 +6656,6 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
|
|||
*/
|
||||
PIXI.CanvasRenderer.prototype.render = function (stage) {
|
||||
|
||||
stage.updateTransform();
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
this.context.globalAlpha = 1;
|
||||
|
@ -10977,7 +10972,7 @@ PIXI.Ellipse = Phaser.Ellipse;
|
|||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
|
@ -11014,7 +11009,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
|
@ -11034,7 +11029,7 @@ Phaser.Line.prototype = {
|
|||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
|
@ -11056,7 +11051,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromAngle
|
||||
* @param {number} x - The x coordinate of the start of the line.
|
||||
* @param {number} y - The y coordinate of the start of the line.
|
||||
|
@ -11075,12 +11070,12 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
* If you wish to rotate around a different point see Line.rotateAround.
|
||||
*
|
||||
*
|
||||
* If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
|
@ -11100,9 +11095,9 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place around the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotateAround
|
||||
* @param {number} x - The x coordinate to offset the rotation from.
|
||||
* @param {number} y - The y coordinate to offset the rotation from.
|
||||
|
@ -11152,7 +11147,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#midPoint
|
||||
* @param {Phaser.Point} [out] - A Phaser.Point object into which the result will be populated. If not given a new Point object is created.
|
||||
* @return {Phaser.Point} A Phaser.Point object with the x and y values set to the center of the line segment.
|
||||
|
@ -11170,10 +11165,10 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Centers this Line on the given coordinates.
|
||||
*
|
||||
*
|
||||
* The line is centered by positioning the start and end points so that the lines midpoint matches
|
||||
* the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#centerOn
|
||||
* @param {number} x - The x position to center the line on.
|
||||
* @param {number} y - The y position to center the line on.
|
||||
|
@ -11194,7 +11189,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -11208,7 +11203,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -11227,7 +11222,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Picks a random point from anywhere on the Line segment and returns it.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#random
|
||||
* @param {Phaser.Point|object} [out] - A Phaser.Point, or any object with public x/y properties, that the values will be set in.
|
||||
* If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object.
|
||||
|
@ -11598,6 +11593,98 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
||||
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
|
||||
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
|
||||
*/
|
||||
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||
|
||||
// Quick bail out of the Line and Rect bounds don't intersect
|
||||
if (!Phaser.Rectangle.intersects(line, rect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var x1 = line.start.x;
|
||||
var y1 = line.start.y;
|
||||
|
||||
var x2 = line.end.x;
|
||||
var y2 = line.end.y;
|
||||
|
||||
var bx1 = rect.x;
|
||||
var by1 = rect.y;
|
||||
var bx2 = rect.right;
|
||||
var by2 = rect.bottom;
|
||||
|
||||
var t = 0;
|
||||
|
||||
// If the start or end of the line is inside the rect then we assume
|
||||
// collision, as rects are solid for our use-case.
|
||||
|
||||
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
||||
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x1 < bx1 && x2 >= bx1)
|
||||
{
|
||||
// Left edge
|
||||
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
||||
|
||||
if (t > by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (x1 > bx2 && x2 <= bx2)
|
||||
{
|
||||
// Right edge
|
||||
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
||||
|
||||
if (t >= by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (y1 < by1 && y2 >= by1)
|
||||
{
|
||||
// Top edge
|
||||
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (y1 > by2 && y2 <= by2)
|
||||
{
|
||||
// Bottom edge
|
||||
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
|
@ -14929,7 +15016,8 @@ Phaser.Camera.prototype = {
|
|||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
this._targetPosition.copyFrom(this.target.world);
|
||||
this._targetPosition.x = this.view.x + this.target.worldPosition.x;
|
||||
this._targetPosition.y = this.view.y + this.target.worldPosition.y;
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
|
@ -15336,6 +15424,11 @@ Phaser.State = function () {
|
|||
*/
|
||||
this.stage = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.StateManager} stage - A reference to the State Manager, which controls state changes.
|
||||
*/
|
||||
this.state = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Time} time - A reference to the game clock and timed events system.
|
||||
*/
|
||||
|
@ -17826,33 +17919,16 @@ Phaser.Stage.prototype.update = function () {
|
|||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
this.updateTransform();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.game.world.camera.update();
|
||||
|
||||
};
|
||||
|
||||
|
@ -18081,7 +18157,7 @@ Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
|||
* In addition, Groups provides support for fast pooling and object recycling.
|
||||
*
|
||||
* Groups are also display objects and can be nested as children within other Groups.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Group
|
||||
* @extends PIXI.DisplayObjectContainer
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -18175,13 +18251,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
this.ignoreDestroy = false;
|
||||
|
||||
/**
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* called on the next logic update.
|
||||
* You can set it directly to flag the Group to be destroyed on its next update.
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
* or a callback of one of its children.
|
||||
*
|
||||
*
|
||||
* @property {boolean} pendingDestroy
|
||||
*/
|
||||
this.pendingDestroy = false;
|
||||
|
@ -18232,7 +18308,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
|
||||
/**
|
||||
* If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.
|
||||
*
|
||||
*
|
||||
* It should be set to one of the Phaser.Physics.Arcade sort direction constants:
|
||||
*
|
||||
* Phaser.Physics.Arcade.SORT_NONE
|
||||
|
@ -20043,6 +20119,80 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the closest child to given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object) {
|
||||
|
||||
var distance = Number.MAX_VALUE;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the child furthest away from the given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getFarthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFarthestFrom = function (object) {
|
||||
|
||||
var distance = 0;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of living children in this group.
|
||||
*
|
||||
|
@ -28151,6 +28301,11 @@ Phaser.Gamepad.prototype = {
|
|||
*/
|
||||
_pollGamepads: function () {
|
||||
|
||||
if (!this._active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator['getGamepads'])
|
||||
{
|
||||
var rawGamepads = navigator.getGamepads();
|
||||
|
@ -28190,6 +28345,11 @@ Phaser.Gamepad.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
for (var g = 0; g < this._gamepads.length; g++)
|
||||
{
|
||||
this._gamepads[g]._rawPad = this._rawPads[g];
|
||||
}
|
||||
|
||||
if (gamepadsChanged)
|
||||
{
|
||||
var validConnections = { rawIndices: {}, padIndices: {} };
|
||||
|
@ -41163,12 +41323,23 @@ Phaser.Text.prototype.updateText = function () {
|
|||
drawnLines = this.style.maxLines;
|
||||
}
|
||||
|
||||
this._charCount = 0;
|
||||
|
||||
for (var i = 0; i < drawnLines; i++)
|
||||
{
|
||||
if (tabs === 0)
|
||||
{
|
||||
// Simple layout (no tabs)
|
||||
var lineWidth = this.context.measureText(lines[i]).width + this.style.strokeThickness + this.padding.x;
|
||||
var lineWidth = this.style.strokeThickness + this.padding.x;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(lines[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += this.context.measureText(lines[i]).width;
|
||||
}
|
||||
|
||||
// Adjust for wrapped text
|
||||
if (this.style.wordWrap)
|
||||
|
@ -41188,7 +41359,16 @@ Phaser.Text.prototype.updateText = function () {
|
|||
|
||||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
var section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
var section = 0;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
section = this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
|
@ -41203,7 +41383,14 @@ Phaser.Text.prototype.updateText = function () {
|
|||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
// How far to the next tab?
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
var diff = this.game.math.snapToCeil(lineWidth, tabs) - lineWidth;
|
||||
|
||||
|
@ -41421,6 +41608,67 @@ Phaser.Text.prototype.updateShadow = function (state) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Measures a line of text character by character taking into the account the specified character styles.
|
||||
*
|
||||
* @method Phaser.Text#measureLine
|
||||
* @private
|
||||
* @param {string} line - The line of text to measure.
|
||||
* @return {integer} length of the line.
|
||||
*/
|
||||
Phaser.Text.prototype.measureLine = function (line) {
|
||||
|
||||
var lineLength = 0;
|
||||
|
||||
for (var i = 0; i < line.length; i++)
|
||||
{
|
||||
var letter = line[i];
|
||||
|
||||
if (this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
var components = this.fontToComponents(this.context.font);
|
||||
|
||||
if (this.fontStyles[this._charCount])
|
||||
{
|
||||
components.fontStyle = this.fontStyles[this._charCount];
|
||||
}
|
||||
|
||||
if (this.fontWeights[this._charCount])
|
||||
{
|
||||
components.fontWeight = this.fontWeights[this._charCount];
|
||||
}
|
||||
|
||||
this.context.font = this.componentsToFont(components);
|
||||
}
|
||||
|
||||
if (this.style.stroke && this.style.strokeThickness)
|
||||
{
|
||||
if (this.strokeColors[this._charCount])
|
||||
{
|
||||
this.context.strokeStyle = this.strokeColors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowStroke);
|
||||
}
|
||||
|
||||
if (this.style.fill)
|
||||
{
|
||||
if (this.colors[this._charCount])
|
||||
{
|
||||
this.context.fillStyle = this.colors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowFill);
|
||||
}
|
||||
|
||||
lineLength += this.context.measureText(letter).width;
|
||||
|
||||
this._charCount++;
|
||||
}
|
||||
|
||||
return Math.ceil(lineLength);
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable.
|
||||
*
|
||||
|
@ -43206,6 +43454,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
var x = 0;
|
||||
var w = 0;
|
||||
var lastSpace = -1;
|
||||
var wrappedWidth = 0;
|
||||
var prevCharCode = null;
|
||||
var maxWidth = (this._maxWidth > 0) ? this._maxWidth : null;
|
||||
var chars = [];
|
||||
|
@ -43237,9 +43486,12 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
// Adjust for kerning from previous character to this one
|
||||
var kerning = (prevCharCode && charData.kerning[prevCharCode]) ? charData.kerning[prevCharCode] : 0;
|
||||
|
||||
// Record the last space in the string
|
||||
lastSpace = /(\s)/.test(text.charAt(i)) ? i : lastSpace;
|
||||
|
||||
// Record the last space in the string and the current width
|
||||
if (/(\s)/.test(text.charAt(i))) {
|
||||
lastSpace = i;
|
||||
wrappedWidth = w;
|
||||
}
|
||||
|
||||
// What will the line width be if we add this character to it?
|
||||
c = (kerning + charData.texture.width + charData.xOffset) * scale;
|
||||
|
||||
|
@ -43247,7 +43499,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
if (maxWidth && ((w + c) >= maxWidth) && lastSpace > -1)
|
||||
{
|
||||
// The last space was at "lastSpace" which was "i - lastSpace" characters ago
|
||||
return { width: w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
return { width: wrappedWidth || w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -52970,7 +53222,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
*
|
||||
*
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
|
@ -53094,10 +53346,10 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
this.onStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`.
|
||||
* Note that the event is only dispatched with the current frame. In a low-FPS environment Animations
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* receive a perfectly sequential set of frames from this event.
|
||||
* @property {Phaser.Signal|null} onUpdate
|
||||
* @default
|
||||
|
@ -53114,6 +53366,12 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
*/
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} isReversed - Indicates if the animation will play backwards.
|
||||
* @default
|
||||
*/
|
||||
this.isReversed = false;
|
||||
|
||||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
@ -53159,7 +53417,7 @@ Phaser.Animation.prototype = {
|
|||
this._timeLastFrame = this.game.time.time;
|
||||
this._timeNextFrame = this.game.time.time + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this._frameIndex = this.isReversed ? this._frames.length - 1 : 0;
|
||||
this.updateCurrentFrame(false, true);
|
||||
|
||||
this._parent.events.onAnimationStart$dispatch(this._parent, this);
|
||||
|
@ -53201,6 +53459,32 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction
|
||||
*
|
||||
* @method Phaser.Animation#reverse
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverse: function () {
|
||||
this.reversed = !this.reversed;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction for the current/next animation only
|
||||
* Once the onComplete event is called this method will be called again and revert
|
||||
* the reversed state.
|
||||
*
|
||||
* @method Phaser.Animation#reverseOnce
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverseOnce: function () {
|
||||
this.onComplete.addOnce(this.reverse.bind(this));
|
||||
|
||||
return this.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animations playback to a given frame with the given ID.
|
||||
*
|
||||
|
@ -53349,14 +53633,23 @@ Phaser.Animation.prototype = {
|
|||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
if (this.isReversed){
|
||||
this._frameIndex -= this._frameSkip;
|
||||
}else{
|
||||
this._frameIndex += this._frameSkip;
|
||||
}
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
if (!this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1)
|
||||
{
|
||||
if (this.loop)
|
||||
{
|
||||
// Update current state before event callback
|
||||
this._frameIndex %= this._frames.length;
|
||||
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
||||
|
||||
if (this.isReversed){
|
||||
this._frameIndex = this._frames.length - 1 - this._frameIndex;
|
||||
}
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
// Instead of calling updateCurrentFrame we do it here instead
|
||||
|
@ -53418,7 +53711,7 @@ Phaser.Animation.prototype = {
|
|||
// The animation is already destroyed, probably from a callback
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Previous index
|
||||
var idx = this.currentFrame.index;
|
||||
|
||||
|
@ -53618,6 +53911,26 @@ Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#reversed
|
||||
* @property {boolean} reversed - Gets and sets the isReversed state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'reversed', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isReversed;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isReversed = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
|
@ -60340,12 +60653,13 @@ Phaser.Sound.prototype = {
|
|||
* @method Phaser.Sound#addMarker
|
||||
* @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc.
|
||||
* @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [duration=1] - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume).
|
||||
* @param {boolean} [loop=false] - Sets if the sound will loop or not.
|
||||
*/
|
||||
addMarker: function (name, start, duration, volume, loop) {
|
||||
|
||||
if (duration === undefined || duration === null) { duration = 1; }
|
||||
if (volume === undefined || volume === null) { volume = 1; }
|
||||
if (loop === undefined) { loop = false; }
|
||||
|
||||
|
@ -68986,6 +69300,9 @@ Phaser.Particles.prototype.constructor = Phaser.Particles;
|
|||
* Small screen devices, especially iPod and iPhone will launch the video in its own native video player,
|
||||
* outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation.
|
||||
*
|
||||
* Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends)
|
||||
* then you need to add your own event listener
|
||||
*
|
||||
* @class Phaser.Video
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -69048,7 +69365,7 @@ Phaser.Video = function (game, key, url) {
|
|||
this.onChangeSource = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. Videos set to loop will never dispatch this signal.
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal.
|
||||
*/
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
|
@ -69619,6 +69936,7 @@ Phaser.Video.prototype = {
|
|||
this._endCallback = this.complete.bind(this);
|
||||
|
||||
this.video.addEventListener('ended', this._endCallback, true);
|
||||
this.video.addEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
|
||||
if (loop)
|
||||
{
|
||||
|
@ -69740,6 +70058,7 @@ Phaser.Video.prototype = {
|
|||
else
|
||||
{
|
||||
this.video.removeEventListener('ended', this._endCallback, true);
|
||||
this.video.removeEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
this.video.removeEventListener('playing', this._playCallback, true);
|
||||
|
||||
if (this.touchLocked)
|
||||
|
|
File diff suppressed because one or more lines are too long
32
build/custom/phaser-no-physics.min.js
vendored
32
build/custom/phaser-no-physics.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:18:04
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:39:22
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -1875,7 +1875,7 @@ PIXI.Ellipse = Phaser.Ellipse;
|
|||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
|
@ -1912,7 +1912,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
|
@ -1932,7 +1932,7 @@ Phaser.Line.prototype = {
|
|||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
|
@ -1954,7 +1954,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromAngle
|
||||
* @param {number} x - The x coordinate of the start of the line.
|
||||
* @param {number} y - The y coordinate of the start of the line.
|
||||
|
@ -1973,12 +1973,12 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
* If you wish to rotate around a different point see Line.rotateAround.
|
||||
*
|
||||
*
|
||||
* If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
|
@ -1998,9 +1998,9 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place around the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotateAround
|
||||
* @param {number} x - The x coordinate to offset the rotation from.
|
||||
* @param {number} y - The y coordinate to offset the rotation from.
|
||||
|
@ -2050,7 +2050,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#midPoint
|
||||
* @param {Phaser.Point} [out] - A Phaser.Point object into which the result will be populated. If not given a new Point object is created.
|
||||
* @return {Phaser.Point} A Phaser.Point object with the x and y values set to the center of the line segment.
|
||||
|
@ -2068,10 +2068,10 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Centers this Line on the given coordinates.
|
||||
*
|
||||
*
|
||||
* The line is centered by positioning the start and end points so that the lines midpoint matches
|
||||
* the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#centerOn
|
||||
* @param {number} x - The x position to center the line on.
|
||||
* @param {number} y - The y position to center the line on.
|
||||
|
@ -2092,7 +2092,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -2106,7 +2106,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -2125,7 +2125,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Picks a random point from anywhere on the Line segment and returns it.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#random
|
||||
* @param {Phaser.Point|object} [out] - A Phaser.Point, or any object with public x/y properties, that the values will be set in.
|
||||
* If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object.
|
||||
|
@ -2496,6 +2496,98 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
||||
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
|
||||
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
|
||||
*/
|
||||
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||
|
||||
// Quick bail out of the Line and Rect bounds don't intersect
|
||||
if (!Phaser.Rectangle.intersects(line, rect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var x1 = line.start.x;
|
||||
var y1 = line.start.y;
|
||||
|
||||
var x2 = line.end.x;
|
||||
var y2 = line.end.y;
|
||||
|
||||
var bx1 = rect.x;
|
||||
var by1 = rect.y;
|
||||
var bx2 = rect.right;
|
||||
var by2 = rect.bottom;
|
||||
|
||||
var t = 0;
|
||||
|
||||
// If the start or end of the line is inside the rect then we assume
|
||||
// collision, as rects are solid for our use-case.
|
||||
|
||||
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
||||
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x1 < bx1 && x2 >= bx1)
|
||||
{
|
||||
// Left edge
|
||||
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
||||
|
||||
if (t > by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (x1 > bx2 && x2 <= bx2)
|
||||
{
|
||||
// Right edge
|
||||
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
||||
|
||||
if (t >= by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (y1 < by1 && y2 >= by1)
|
||||
{
|
||||
// Top edge
|
||||
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (y1 > by2 && y2 <= by2)
|
||||
{
|
||||
// Bottom edge
|
||||
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
|
@ -5827,7 +5919,8 @@ Phaser.Camera.prototype = {
|
|||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
this._targetPosition.copyFrom(this.target.world);
|
||||
this._targetPosition.x = this.view.x + this.target.worldPosition.x;
|
||||
this._targetPosition.y = this.view.y + this.target.worldPosition.y;
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
|
@ -6234,6 +6327,11 @@ Phaser.State = function () {
|
|||
*/
|
||||
this.stage = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.StateManager} stage - A reference to the State Manager, which controls state changes.
|
||||
*/
|
||||
this.state = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Time} time - A reference to the game clock and timed events system.
|
||||
*/
|
||||
|
@ -8724,33 +8822,16 @@ Phaser.Stage.prototype.update = function () {
|
|||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
this.updateTransform();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.game.world.camera.update();
|
||||
|
||||
};
|
||||
|
||||
|
@ -8979,7 +9060,7 @@ Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
|||
* In addition, Groups provides support for fast pooling and object recycling.
|
||||
*
|
||||
* Groups are also display objects and can be nested as children within other Groups.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Group
|
||||
* @extends PIXI.DisplayObjectContainer
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -9073,13 +9154,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
this.ignoreDestroy = false;
|
||||
|
||||
/**
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* called on the next logic update.
|
||||
* You can set it directly to flag the Group to be destroyed on its next update.
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
* or a callback of one of its children.
|
||||
*
|
||||
*
|
||||
* @property {boolean} pendingDestroy
|
||||
*/
|
||||
this.pendingDestroy = false;
|
||||
|
@ -9130,7 +9211,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
|
||||
/**
|
||||
* If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.
|
||||
*
|
||||
*
|
||||
* It should be set to one of the Phaser.Physics.Arcade sort direction constants:
|
||||
*
|
||||
* Phaser.Physics.Arcade.SORT_NONE
|
||||
|
@ -10941,6 +11022,80 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the closest child to given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object) {
|
||||
|
||||
var distance = Number.MAX_VALUE;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the child furthest away from the given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getFarthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFarthestFrom = function (object) {
|
||||
|
||||
var distance = 0;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of living children in this group.
|
||||
*
|
||||
|
@ -19049,6 +19204,11 @@ Phaser.Gamepad.prototype = {
|
|||
*/
|
||||
_pollGamepads: function () {
|
||||
|
||||
if (!this._active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator['getGamepads'])
|
||||
{
|
||||
var rawGamepads = navigator.getGamepads();
|
||||
|
@ -19088,6 +19248,11 @@ Phaser.Gamepad.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
for (var g = 0; g < this._gamepads.length; g++)
|
||||
{
|
||||
this._gamepads[g]._rawPad = this._rawPads[g];
|
||||
}
|
||||
|
||||
if (gamepadsChanged)
|
||||
{
|
||||
var validConnections = { rawIndices: {}, padIndices: {} };
|
||||
|
@ -32061,12 +32226,23 @@ Phaser.Text.prototype.updateText = function () {
|
|||
drawnLines = this.style.maxLines;
|
||||
}
|
||||
|
||||
this._charCount = 0;
|
||||
|
||||
for (var i = 0; i < drawnLines; i++)
|
||||
{
|
||||
if (tabs === 0)
|
||||
{
|
||||
// Simple layout (no tabs)
|
||||
var lineWidth = this.context.measureText(lines[i]).width + this.style.strokeThickness + this.padding.x;
|
||||
var lineWidth = this.style.strokeThickness + this.padding.x;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(lines[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += this.context.measureText(lines[i]).width;
|
||||
}
|
||||
|
||||
// Adjust for wrapped text
|
||||
if (this.style.wordWrap)
|
||||
|
@ -32086,7 +32262,16 @@ Phaser.Text.prototype.updateText = function () {
|
|||
|
||||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
var section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
var section = 0;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
section = this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
|
@ -32101,7 +32286,14 @@ Phaser.Text.prototype.updateText = function () {
|
|||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
// How far to the next tab?
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
var diff = this.game.math.snapToCeil(lineWidth, tabs) - lineWidth;
|
||||
|
||||
|
@ -32319,6 +32511,67 @@ Phaser.Text.prototype.updateShadow = function (state) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Measures a line of text character by character taking into the account the specified character styles.
|
||||
*
|
||||
* @method Phaser.Text#measureLine
|
||||
* @private
|
||||
* @param {string} line - The line of text to measure.
|
||||
* @return {integer} length of the line.
|
||||
*/
|
||||
Phaser.Text.prototype.measureLine = function (line) {
|
||||
|
||||
var lineLength = 0;
|
||||
|
||||
for (var i = 0; i < line.length; i++)
|
||||
{
|
||||
var letter = line[i];
|
||||
|
||||
if (this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
var components = this.fontToComponents(this.context.font);
|
||||
|
||||
if (this.fontStyles[this._charCount])
|
||||
{
|
||||
components.fontStyle = this.fontStyles[this._charCount];
|
||||
}
|
||||
|
||||
if (this.fontWeights[this._charCount])
|
||||
{
|
||||
components.fontWeight = this.fontWeights[this._charCount];
|
||||
}
|
||||
|
||||
this.context.font = this.componentsToFont(components);
|
||||
}
|
||||
|
||||
if (this.style.stroke && this.style.strokeThickness)
|
||||
{
|
||||
if (this.strokeColors[this._charCount])
|
||||
{
|
||||
this.context.strokeStyle = this.strokeColors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowStroke);
|
||||
}
|
||||
|
||||
if (this.style.fill)
|
||||
{
|
||||
if (this.colors[this._charCount])
|
||||
{
|
||||
this.context.fillStyle = this.colors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowFill);
|
||||
}
|
||||
|
||||
lineLength += this.context.measureText(letter).width;
|
||||
|
||||
this._charCount++;
|
||||
}
|
||||
|
||||
return Math.ceil(lineLength);
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable.
|
||||
*
|
||||
|
@ -34104,6 +34357,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
var x = 0;
|
||||
var w = 0;
|
||||
var lastSpace = -1;
|
||||
var wrappedWidth = 0;
|
||||
var prevCharCode = null;
|
||||
var maxWidth = (this._maxWidth > 0) ? this._maxWidth : null;
|
||||
var chars = [];
|
||||
|
@ -34135,9 +34389,12 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
// Adjust for kerning from previous character to this one
|
||||
var kerning = (prevCharCode && charData.kerning[prevCharCode]) ? charData.kerning[prevCharCode] : 0;
|
||||
|
||||
// Record the last space in the string
|
||||
lastSpace = /(\s)/.test(text.charAt(i)) ? i : lastSpace;
|
||||
|
||||
// Record the last space in the string and the current width
|
||||
if (/(\s)/.test(text.charAt(i))) {
|
||||
lastSpace = i;
|
||||
wrappedWidth = w;
|
||||
}
|
||||
|
||||
// What will the line width be if we add this character to it?
|
||||
c = (kerning + charData.texture.width + charData.xOffset) * scale;
|
||||
|
||||
|
@ -34145,7 +34402,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
if (maxWidth && ((w + c) >= maxWidth) && lastSpace > -1)
|
||||
{
|
||||
// The last space was at "lastSpace" which was "i - lastSpace" characters ago
|
||||
return { width: w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
return { width: wrappedWidth || w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43868,7 +44125,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
*
|
||||
*
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
|
@ -43992,10 +44249,10 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
this.onStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`.
|
||||
* Note that the event is only dispatched with the current frame. In a low-FPS environment Animations
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* receive a perfectly sequential set of frames from this event.
|
||||
* @property {Phaser.Signal|null} onUpdate
|
||||
* @default
|
||||
|
@ -44012,6 +44269,12 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
*/
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} isReversed - Indicates if the animation will play backwards.
|
||||
* @default
|
||||
*/
|
||||
this.isReversed = false;
|
||||
|
||||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
@ -44057,7 +44320,7 @@ Phaser.Animation.prototype = {
|
|||
this._timeLastFrame = this.game.time.time;
|
||||
this._timeNextFrame = this.game.time.time + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this._frameIndex = this.isReversed ? this._frames.length - 1 : 0;
|
||||
this.updateCurrentFrame(false, true);
|
||||
|
||||
this._parent.events.onAnimationStart$dispatch(this._parent, this);
|
||||
|
@ -44099,6 +44362,32 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction
|
||||
*
|
||||
* @method Phaser.Animation#reverse
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverse: function () {
|
||||
this.reversed = !this.reversed;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction for the current/next animation only
|
||||
* Once the onComplete event is called this method will be called again and revert
|
||||
* the reversed state.
|
||||
*
|
||||
* @method Phaser.Animation#reverseOnce
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverseOnce: function () {
|
||||
this.onComplete.addOnce(this.reverse.bind(this));
|
||||
|
||||
return this.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animations playback to a given frame with the given ID.
|
||||
*
|
||||
|
@ -44247,14 +44536,23 @@ Phaser.Animation.prototype = {
|
|||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
if (this.isReversed){
|
||||
this._frameIndex -= this._frameSkip;
|
||||
}else{
|
||||
this._frameIndex += this._frameSkip;
|
||||
}
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
if (!this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1)
|
||||
{
|
||||
if (this.loop)
|
||||
{
|
||||
// Update current state before event callback
|
||||
this._frameIndex %= this._frames.length;
|
||||
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
||||
|
||||
if (this.isReversed){
|
||||
this._frameIndex = this._frames.length - 1 - this._frameIndex;
|
||||
}
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
// Instead of calling updateCurrentFrame we do it here instead
|
||||
|
@ -44316,7 +44614,7 @@ Phaser.Animation.prototype = {
|
|||
// The animation is already destroyed, probably from a callback
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Previous index
|
||||
var idx = this.currentFrame.index;
|
||||
|
||||
|
@ -44516,6 +44814,26 @@ Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#reversed
|
||||
* @property {boolean} reversed - Gets and sets the isReversed state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'reversed', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isReversed;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isReversed = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
|
@ -51238,12 +51556,13 @@ Phaser.Sound.prototype = {
|
|||
* @method Phaser.Sound#addMarker
|
||||
* @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc.
|
||||
* @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [duration=1] - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume).
|
||||
* @param {boolean} [loop=false] - Sets if the sound will loop or not.
|
||||
*/
|
||||
addMarker: function (name, start, duration, volume, loop) {
|
||||
|
||||
if (duration === undefined || duration === null) { duration = 1; }
|
||||
if (volume === undefined || volume === null) { volume = 1; }
|
||||
if (loop === undefined) { loop = false; }
|
||||
|
||||
|
@ -60763,6 +61082,11 @@ Phaser.Physics.Arcade.prototype = {
|
|||
*/
|
||||
intersects: function (body1, body2) {
|
||||
|
||||
if (body1 === body2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rect vs. Rect
|
||||
if (body1.right <= body2.position.x)
|
||||
{
|
||||
|
@ -62204,11 +62528,6 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
setSize: function (width, height, offsetX, offsetY) {
|
||||
|
||||
if (this.isCircle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetX === undefined) { offsetX = this.offset.x; }
|
||||
if (offsetY === undefined) { offsetY = this.offset.y; }
|
||||
|
||||
|
@ -62269,7 +62588,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
hitTest: function (x, y) {
|
||||
|
||||
return (this.isCircle) ? Phaser.Circle.contains(this, x, y) : Phaser.Rectangle.contains(this, x, y);
|
||||
return Phaser.Rectangle.contains(this, x, y);
|
||||
|
||||
},
|
||||
|
||||
|
@ -74368,6 +74687,9 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
|
|||
* Small screen devices, especially iPod and iPhone will launch the video in its own native video player,
|
||||
* outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation.
|
||||
*
|
||||
* Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends)
|
||||
* then you need to add your own event listener
|
||||
*
|
||||
* @class Phaser.Video
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -74430,7 +74752,7 @@ Phaser.Video = function (game, key, url) {
|
|||
this.onChangeSource = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. Videos set to loop will never dispatch this signal.
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal.
|
||||
*/
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
|
@ -75001,6 +75323,7 @@ Phaser.Video.prototype = {
|
|||
this._endCallback = this.complete.bind(this);
|
||||
|
||||
this.video.addEventListener('ended', this._endCallback, true);
|
||||
this.video.addEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
|
||||
if (loop)
|
||||
{
|
||||
|
@ -75122,6 +75445,7 @@ Phaser.Video.prototype = {
|
|||
else
|
||||
{
|
||||
this.video.removeEventListener('ended', this._endCallback, true);
|
||||
this.video.removeEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
this.video.removeEventListener('playing', this._playCallback, true);
|
||||
|
||||
if (this.touchLocked)
|
||||
|
|
File diff suppressed because one or more lines are too long
36
build/custom/phaser-split.min.js
vendored
36
build/custom/phaser-split.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:18:03
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:39:21
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -3676,9 +3676,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
return;
|
||||
}
|
||||
|
||||
// update the scene graph
|
||||
stage.updateTransform();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// -- Does this need to be set every frame? -- //
|
||||
|
@ -6659,8 +6656,6 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
|
|||
*/
|
||||
PIXI.CanvasRenderer.prototype.render = function (stage) {
|
||||
|
||||
stage.updateTransform();
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
this.context.globalAlpha = 1;
|
||||
|
|
File diff suppressed because one or more lines are too long
4
build/custom/pixi.min.js
vendored
4
build/custom/pixi.min.js
vendored
File diff suppressed because one or more lines are too long
467
build/phaser.js
467
build/phaser.js
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Phaser - http://phaser.io
|
||||
*
|
||||
* v2.4.9 "Four Kings" - Built: Mon May 23 2016 13:17:27
|
||||
* v2.4.9 "Four Kings" - Built: Thu Jun 02 2016 16:38:43
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
|
@ -17289,9 +17289,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
return;
|
||||
}
|
||||
|
||||
// update the scene graph
|
||||
stage.updateTransform();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// -- Does this need to be set every frame? -- //
|
||||
|
@ -20272,8 +20269,6 @@ PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
|
|||
*/
|
||||
PIXI.CanvasRenderer.prototype.render = function (stage) {
|
||||
|
||||
stage.updateTransform();
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
this.context.globalAlpha = 1;
|
||||
|
@ -24590,7 +24585,7 @@ PIXI.Ellipse = Phaser.Ellipse;
|
|||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
|
@ -24627,7 +24622,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
|
@ -24647,7 +24642,7 @@ Phaser.Line.prototype = {
|
|||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
|
@ -24669,7 +24664,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#fromAngle
|
||||
* @param {number} x - The x coordinate of the start of the line.
|
||||
* @param {number} y - The y coordinate of the start of the line.
|
||||
|
@ -24688,12 +24683,12 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
* If you wish to rotate around a different point see Line.rotateAround.
|
||||
*
|
||||
*
|
||||
* If you wish to rotate the ends of the Line then see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
|
@ -24713,9 +24708,9 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
*
|
||||
* Rotation takes place around the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#rotateAround
|
||||
* @param {number} x - The x coordinate to offset the rotation from.
|
||||
* @param {number} y - The y coordinate to offset the rotation from.
|
||||
|
@ -24765,7 +24760,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Returns a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#midPoint
|
||||
* @param {Phaser.Point} [out] - A Phaser.Point object into which the result will be populated. If not given a new Point object is created.
|
||||
* @return {Phaser.Point} A Phaser.Point object with the x and y values set to the center of the line segment.
|
||||
|
@ -24783,10 +24778,10 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Centers this Line on the given coordinates.
|
||||
*
|
||||
*
|
||||
* The line is centered by positioning the start and end points so that the lines midpoint matches
|
||||
* the coordinates given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#centerOn
|
||||
* @param {number} x - The x position to center the line on.
|
||||
* @param {number} y - The y position to center the line on.
|
||||
|
@ -24807,7 +24802,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -24821,7 +24816,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
|
@ -24840,7 +24835,7 @@ Phaser.Line.prototype = {
|
|||
|
||||
/**
|
||||
* Picks a random point from anywhere on the Line segment and returns it.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Line#random
|
||||
* @param {Phaser.Point|object} [out] - A Phaser.Point, or any object with public x/y properties, that the values will be set in.
|
||||
* If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an object.
|
||||
|
@ -25211,6 +25206,98 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between the Line and a Rectangle shape, or a rectangle-like
|
||||
* object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body.
|
||||
*
|
||||
* An intersection is considered valid if:
|
||||
*
|
||||
* The line starts within, or ends within, the Rectangle.
|
||||
* The line segment intersects one of the 4 rectangle edges.
|
||||
*
|
||||
* The for the purposes of this function rectangles are considered 'solid'.
|
||||
*
|
||||
* @method intersectsRectangle
|
||||
* @param {Phaser.Line} line - The line to check for intersection with.
|
||||
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
|
||||
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
|
||||
*/
|
||||
Phaser.Line.intersectsRectangle = function (line, rect) {
|
||||
|
||||
// Quick bail out of the Line and Rect bounds don't intersect
|
||||
if (!Phaser.Rectangle.intersects(line, rect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var x1 = line.start.x;
|
||||
var y1 = line.start.y;
|
||||
|
||||
var x2 = line.end.x;
|
||||
var y2 = line.end.y;
|
||||
|
||||
var bx1 = rect.x;
|
||||
var by1 = rect.y;
|
||||
var bx2 = rect.right;
|
||||
var by2 = rect.bottom;
|
||||
|
||||
var t = 0;
|
||||
|
||||
// If the start or end of the line is inside the rect then we assume
|
||||
// collision, as rects are solid for our use-case.
|
||||
|
||||
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
||||
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (x1 < bx1 && x2 >= bx1)
|
||||
{
|
||||
// Left edge
|
||||
t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1);
|
||||
|
||||
if (t > by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (x1 > bx2 && x2 <= bx2)
|
||||
{
|
||||
// Right edge
|
||||
t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1);
|
||||
|
||||
if (t >= by1 && t <= by2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (y1 < by1 && y2 >= by1)
|
||||
{
|
||||
// Top edge
|
||||
t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (y1 > by2 && y2 <= by2)
|
||||
{
|
||||
// Bottom edge
|
||||
t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1);
|
||||
|
||||
if (t >= bx1 && t <= bx2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the reflected angle between two lines.
|
||||
* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
|
||||
|
@ -28542,7 +28629,8 @@ Phaser.Camera.prototype = {
|
|||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
this._targetPosition.copyFrom(this.target.world);
|
||||
this._targetPosition.x = this.view.x + this.target.worldPosition.x;
|
||||
this._targetPosition.y = this.view.y + this.target.worldPosition.y;
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
|
@ -28949,6 +29037,11 @@ Phaser.State = function () {
|
|||
*/
|
||||
this.stage = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.StateManager} stage - A reference to the State Manager, which controls state changes.
|
||||
*/
|
||||
this.state = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Time} time - A reference to the game clock and timed events system.
|
||||
*/
|
||||
|
@ -31439,33 +31532,16 @@ Phaser.Stage.prototype.update = function () {
|
|||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
this.updateTransform();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
this.game.world.camera.update();
|
||||
|
||||
};
|
||||
|
||||
|
@ -31694,7 +31770,7 @@ Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
|||
* In addition, Groups provides support for fast pooling and object recycling.
|
||||
*
|
||||
* Groups are also display objects and can be nested as children within other Groups.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Group
|
||||
* @extends PIXI.DisplayObjectContainer
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -31788,13 +31864,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
this.ignoreDestroy = false;
|
||||
|
||||
/**
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method
|
||||
* called on the next logic update.
|
||||
* You can set it directly to flag the Group to be destroyed on its next update.
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
*
|
||||
* This is extremely useful if you wish to destroy a Group from within one of its own callbacks
|
||||
* or a callback of one of its children.
|
||||
*
|
||||
*
|
||||
* @property {boolean} pendingDestroy
|
||||
*/
|
||||
this.pendingDestroy = false;
|
||||
|
@ -31845,7 +31921,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
|
|||
|
||||
/**
|
||||
* If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.
|
||||
*
|
||||
*
|
||||
* It should be set to one of the Phaser.Physics.Arcade sort direction constants:
|
||||
*
|
||||
* Phaser.Physics.Arcade.SORT_NONE
|
||||
|
@ -33656,6 +33732,80 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the closest child to given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object) {
|
||||
|
||||
var distance = Number.MAX_VALUE;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the child furthest away from the given Object.
|
||||
*
|
||||
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* @method Phaser.Group#getFarthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFarthestFrom = function (object) {
|
||||
|
||||
var distance = 0;
|
||||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
||||
if (child.exists)
|
||||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance)
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of living children in this group.
|
||||
*
|
||||
|
@ -41764,6 +41914,11 @@ Phaser.Gamepad.prototype = {
|
|||
*/
|
||||
_pollGamepads: function () {
|
||||
|
||||
if (!this._active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator['getGamepads'])
|
||||
{
|
||||
var rawGamepads = navigator.getGamepads();
|
||||
|
@ -41803,6 +41958,11 @@ Phaser.Gamepad.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
for (var g = 0; g < this._gamepads.length; g++)
|
||||
{
|
||||
this._gamepads[g]._rawPad = this._rawPads[g];
|
||||
}
|
||||
|
||||
if (gamepadsChanged)
|
||||
{
|
||||
var validConnections = { rawIndices: {}, padIndices: {} };
|
||||
|
@ -54776,12 +54936,23 @@ Phaser.Text.prototype.updateText = function () {
|
|||
drawnLines = this.style.maxLines;
|
||||
}
|
||||
|
||||
this._charCount = 0;
|
||||
|
||||
for (var i = 0; i < drawnLines; i++)
|
||||
{
|
||||
if (tabs === 0)
|
||||
{
|
||||
// Simple layout (no tabs)
|
||||
var lineWidth = this.context.measureText(lines[i]).width + this.style.strokeThickness + this.padding.x;
|
||||
var lineWidth = this.style.strokeThickness + this.padding.x;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(lines[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += this.context.measureText(lines[i]).width;
|
||||
}
|
||||
|
||||
// Adjust for wrapped text
|
||||
if (this.style.wordWrap)
|
||||
|
@ -54801,7 +54972,16 @@ Phaser.Text.prototype.updateText = function () {
|
|||
|
||||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
var section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
var section = 0;
|
||||
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
section = this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
section = Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
|
@ -54816,7 +54996,14 @@ Phaser.Text.prototype.updateText = function () {
|
|||
for (var c = 0; c < line.length; c++)
|
||||
{
|
||||
// How far to the next tab?
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
lineWidth += this.measureLine(line[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
||||
}
|
||||
|
||||
var diff = this.game.math.snapToCeil(lineWidth, tabs) - lineWidth;
|
||||
|
||||
|
@ -55034,6 +55221,67 @@ Phaser.Text.prototype.updateShadow = function (state) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* Measures a line of text character by character taking into the account the specified character styles.
|
||||
*
|
||||
* @method Phaser.Text#measureLine
|
||||
* @private
|
||||
* @param {string} line - The line of text to measure.
|
||||
* @return {integer} length of the line.
|
||||
*/
|
||||
Phaser.Text.prototype.measureLine = function (line) {
|
||||
|
||||
var lineLength = 0;
|
||||
|
||||
for (var i = 0; i < line.length; i++)
|
||||
{
|
||||
var letter = line[i];
|
||||
|
||||
if (this.fontWeights.length > 0 || this.fontStyles.length > 0)
|
||||
{
|
||||
var components = this.fontToComponents(this.context.font);
|
||||
|
||||
if (this.fontStyles[this._charCount])
|
||||
{
|
||||
components.fontStyle = this.fontStyles[this._charCount];
|
||||
}
|
||||
|
||||
if (this.fontWeights[this._charCount])
|
||||
{
|
||||
components.fontWeight = this.fontWeights[this._charCount];
|
||||
}
|
||||
|
||||
this.context.font = this.componentsToFont(components);
|
||||
}
|
||||
|
||||
if (this.style.stroke && this.style.strokeThickness)
|
||||
{
|
||||
if (this.strokeColors[this._charCount])
|
||||
{
|
||||
this.context.strokeStyle = this.strokeColors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowStroke);
|
||||
}
|
||||
|
||||
if (this.style.fill)
|
||||
{
|
||||
if (this.colors[this._charCount])
|
||||
{
|
||||
this.context.fillStyle = this.colors[this._charCount];
|
||||
}
|
||||
|
||||
this.updateShadow(this.style.shadowFill);
|
||||
}
|
||||
|
||||
lineLength += this.context.measureText(letter).width;
|
||||
|
||||
this._charCount++;
|
||||
}
|
||||
|
||||
return Math.ceil(lineLength);
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a line of text, applying fill and stroke per-character colors or style and weight per-character font if applicable.
|
||||
*
|
||||
|
@ -56819,6 +57067,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
var x = 0;
|
||||
var w = 0;
|
||||
var lastSpace = -1;
|
||||
var wrappedWidth = 0;
|
||||
var prevCharCode = null;
|
||||
var maxWidth = (this._maxWidth > 0) ? this._maxWidth : null;
|
||||
var chars = [];
|
||||
|
@ -56850,9 +57099,12 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
// Adjust for kerning from previous character to this one
|
||||
var kerning = (prevCharCode && charData.kerning[prevCharCode]) ? charData.kerning[prevCharCode] : 0;
|
||||
|
||||
// Record the last space in the string
|
||||
lastSpace = /(\s)/.test(text.charAt(i)) ? i : lastSpace;
|
||||
|
||||
// Record the last space in the string and the current width
|
||||
if (/(\s)/.test(text.charAt(i))) {
|
||||
lastSpace = i;
|
||||
wrappedWidth = w;
|
||||
}
|
||||
|
||||
// What will the line width be if we add this character to it?
|
||||
c = (kerning + charData.texture.width + charData.xOffset) * scale;
|
||||
|
||||
|
@ -56860,7 +57112,7 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
|
|||
if (maxWidth && ((w + c) >= maxWidth) && lastSpace > -1)
|
||||
{
|
||||
// The last space was at "lastSpace" which was "i - lastSpace" characters ago
|
||||
return { width: w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
return { width: wrappedWidth || w, text: text.substr(0, i - (i - lastSpace)), end: end, chars: chars };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66583,7 +66835,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
*
|
||||
*
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
|
@ -66707,10 +66959,10 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
this.onStart = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* This event is dispatched when the Animation changes frame.
|
||||
* By default this event is disabled due to its intensive nature. Enable it with: `Animation.enableUpdate = true`.
|
||||
* Note that the event is only dispatched with the current frame. In a low-FPS environment Animations
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* will automatically frame-skip to try and claw back time, so do not base your code on expecting to
|
||||
* receive a perfectly sequential set of frames from this event.
|
||||
* @property {Phaser.Signal|null} onUpdate
|
||||
* @default
|
||||
|
@ -66727,6 +66979,12 @@ Phaser.Animation = function (game, parent, name, frameData, frames, frameRate, l
|
|||
*/
|
||||
this.onLoop = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {boolean} isReversed - Indicates if the animation will play backwards.
|
||||
* @default
|
||||
*/
|
||||
this.isReversed = false;
|
||||
|
||||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
@ -66772,7 +67030,7 @@ Phaser.Animation.prototype = {
|
|||
this._timeLastFrame = this.game.time.time;
|
||||
this._timeNextFrame = this.game.time.time + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this._frameIndex = this.isReversed ? this._frames.length - 1 : 0;
|
||||
this.updateCurrentFrame(false, true);
|
||||
|
||||
this._parent.events.onAnimationStart$dispatch(this._parent, this);
|
||||
|
@ -66814,6 +67072,32 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction
|
||||
*
|
||||
* @method Phaser.Animation#reverse
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverse: function () {
|
||||
this.reversed = !this.reversed;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the animation direction for the current/next animation only
|
||||
* Once the onComplete event is called this method will be called again and revert
|
||||
* the reversed state.
|
||||
*
|
||||
* @method Phaser.Animation#reverseOnce
|
||||
* @return {Phaser.Animation} The animation instance.
|
||||
* */
|
||||
reverseOnce: function () {
|
||||
this.onComplete.addOnce(this.reverse.bind(this));
|
||||
|
||||
return this.reverse();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animations playback to a given frame with the given ID.
|
||||
*
|
||||
|
@ -66962,14 +67246,23 @@ Phaser.Animation.prototype = {
|
|||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
if (this.isReversed){
|
||||
this._frameIndex -= this._frameSkip;
|
||||
}else{
|
||||
this._frameIndex += this._frameSkip;
|
||||
}
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
if (!this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1)
|
||||
{
|
||||
if (this.loop)
|
||||
{
|
||||
// Update current state before event callback
|
||||
this._frameIndex %= this._frames.length;
|
||||
this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
|
||||
|
||||
if (this.isReversed){
|
||||
this._frameIndex = this._frames.length - 1 - this._frameIndex;
|
||||
}
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
// Instead of calling updateCurrentFrame we do it here instead
|
||||
|
@ -67031,7 +67324,7 @@ Phaser.Animation.prototype = {
|
|||
// The animation is already destroyed, probably from a callback
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Previous index
|
||||
var idx = this.currentFrame.index;
|
||||
|
||||
|
@ -67231,6 +67524,26 @@ Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#reversed
|
||||
* @property {boolean} reversed - Gets and sets the isReversed state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'reversed', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isReversed;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isReversed = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
|
@ -73953,12 +74266,13 @@ Phaser.Sound.prototype = {
|
|||
* @method Phaser.Sound#addMarker
|
||||
* @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc.
|
||||
* @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [duration=1] - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
|
||||
* @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume).
|
||||
* @param {boolean} [loop=false] - Sets if the sound will loop or not.
|
||||
*/
|
||||
addMarker: function (name, start, duration, volume, loop) {
|
||||
|
||||
if (duration === undefined || duration === null) { duration = 1; }
|
||||
if (volume === undefined || volume === null) { volume = 1; }
|
||||
if (loop === undefined) { loop = false; }
|
||||
|
||||
|
@ -83478,6 +83792,11 @@ Phaser.Physics.Arcade.prototype = {
|
|||
*/
|
||||
intersects: function (body1, body2) {
|
||||
|
||||
if (body1 === body2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rect vs. Rect
|
||||
if (body1.right <= body2.position.x)
|
||||
{
|
||||
|
@ -84919,11 +85238,6 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
setSize: function (width, height, offsetX, offsetY) {
|
||||
|
||||
if (this.isCircle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (offsetX === undefined) { offsetX = this.offset.x; }
|
||||
if (offsetY === undefined) { offsetY = this.offset.y; }
|
||||
|
||||
|
@ -84984,7 +85298,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
hitTest: function (x, y) {
|
||||
|
||||
return (this.isCircle) ? Phaser.Circle.contains(this, x, y) : Phaser.Rectangle.contains(this, x, y);
|
||||
return Phaser.Rectangle.contains(this, x, y);
|
||||
|
||||
},
|
||||
|
||||
|
@ -97083,6 +97397,9 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
|
|||
* Small screen devices, especially iPod and iPhone will launch the video in its own native video player,
|
||||
* outside of the Safari browser. There is no way to avoid this, it's a device imposed limitation.
|
||||
*
|
||||
* Note: On iOS if you need to detect when the user presses the 'Done' button (before the video ends)
|
||||
* then you need to add your own event listener
|
||||
*
|
||||
* @class Phaser.Video
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
|
@ -97145,7 +97462,7 @@ Phaser.Video = function (game, key, url) {
|
|||
this.onChangeSource = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. Videos set to loop will never dispatch this signal.
|
||||
* @property {Phaser.Signal} onComplete - This signal is dispatched when the Video completes playback, i.e. enters an 'ended' state. On iOS specifically it also fires if the user hits the 'Done' button at any point during playback. Videos set to loop will never dispatch this signal.
|
||||
*/
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
|
@ -97716,6 +98033,7 @@ Phaser.Video.prototype = {
|
|||
this._endCallback = this.complete.bind(this);
|
||||
|
||||
this.video.addEventListener('ended', this._endCallback, true);
|
||||
this.video.addEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
|
||||
if (loop)
|
||||
{
|
||||
|
@ -97837,6 +98155,7 @@ Phaser.Video.prototype = {
|
|||
else
|
||||
{
|
||||
this.video.removeEventListener('ended', this._endCallback, true);
|
||||
this.video.removeEventListener('webkitendfullscreen', this._endCallback, true);
|
||||
this.video.removeEventListener('playing', this._playCallback, true);
|
||||
|
||||
if (this.touchLocked)
|
||||
|
|
File diff suppressed because one or more lines are too long
40
build/phaser.min.js
vendored
40
build/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue