From 118d2057c0ea9db0b2ae96f910bd31e20875ec09 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Sat, 23 Jul 2016 12:04:11 -0700 Subject: [PATCH 01/33] Allow animation speed greater than 0 --- src/animation/Animation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 32b9638c3..dce6aa9c6 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -768,19 +768,19 @@ Object.defineProperty(Phaser.Animation.prototype, 'frame', { /** * @name Phaser.Animation#speed -* @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Minimum value is 1. +* @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Value must be greater than 0. */ Object.defineProperty(Phaser.Animation.prototype, 'speed', { get: function () { - return Math.round(1000 / this.delay); + return 1000 / this.delay; }, set: function (value) { - if (value >= 1) + if (value > 0) { this.delay = 1000 / value; } From 3e1595ffafc51f39921f0f7dd69792d889957647 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 26 Jul 2016 14:57:48 +0100 Subject: [PATCH 02/33] Removed debugger calls. --- src/pixi/renderers/webgl/shaders/PixiShader.js | 1 - src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index a9b5aed14..9dd08f6ec 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -180,7 +180,6 @@ PIXI.PixiShader.prototype.initUniforms = function() if (type === 'sampler2D') { - debugger; uniform._init = false; if (uniform.value !== null) diff --git a/src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js index 0b73e2d8b..58a676492 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js @@ -179,9 +179,8 @@ PIXI.WebGLFastSpriteBatch.prototype.end = function() * @method render * @param spriteBatch {WebGLSpriteBatch} */ -PIXI.WebGLFastSpriteBatch.prototype.render = function(spriteBatch) +PIXI.WebGLFastSpriteBatch.prototype.render = function (spriteBatch) { - debugger; var children = spriteBatch.children; var sprite = children[0]; @@ -369,8 +368,6 @@ PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite) */ PIXI.WebGLFastSpriteBatch.prototype.flush = function() { - debugger; - // If the batch is length 0 then return as there is nothing to draw if (this.currentBatchSize===0)return; From 6e3581767551408ddcc3993f9d02def87372b560 Mon Sep 17 00:00:00 2001 From: Felipe Alfonso Date: Tue, 26 Jul 2016 11:49:21 -0400 Subject: [PATCH 03/33] Fixed issue with multiple "texture not bound to unit X" webgl warning --- src/pixi/renderers/webgl/shaders/PixiFastShader.js | 13 ++++++++----- src/pixi/renderers/webgl/shaders/PixiShader.js | 13 ++++++++----- src/pixi/renderers/webgl/shaders/StripShader.js | 13 ++++++++----- src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index d72d809d5..7fab17c9e 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -125,14 +125,17 @@ PIXI.PixiFastShader.prototype.init = function () { this.uSampler = gl.getUniformLocation(program, 'uSamplerArray[0]'); var indices = []; + // HACK: we bind an empty texture to avoid WebGL warning spam. + var tempTexture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); for (var i = 0; i < this.MAX_TEXTURES; ++i) { + gl.activeTexture(gl.TEXTURE0 + i); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); indices.push(i); } - // NOTE:!!! - // If textures are not bound - // then we'll get a bunch of warnings like: - // "WARNING: there is no texture bound to the unit X" - // Don't be scared, everything will be alright. + gl.activeTexture(gl.TEXTURE0); gl.uniform1iv(this.uSampler, indices); this.projectionVector = gl.getUniformLocation(program, 'projectionVector'); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 9dd08f6ec..2f6e7c327 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -121,14 +121,17 @@ PIXI.PixiShader.prototype.init = function() this.aTextureIndex = gl.getAttribLocation(program, 'aTextureIndex'); var indices = []; + // HACK: we bind an empty texture to avoid WebGL warning spam. + var tempTexture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); for (var i = 0; i < this.MAX_TEXTURES; ++i) { + gl.activeTexture(gl.TEXTURE0 + i); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); indices.push(i); } - // NOTE:!!! - // If textures are not bound - // then we'll get a bunch of warnings like: - // "WARNING: there is no texture bound to the unit X" - // Don't be scared, everything will be alright. + gl.activeTexture(gl.TEXTURE0); gl.uniform1iv(this.uSamplerArray, indices); // Begin worst hack eva // diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 0a4542874..74ceb0f02 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -111,14 +111,17 @@ PIXI.StripShader.prototype.init = function() this.uSampler = gl.getUniformLocation(program, 'uSamplerArray[0]'); var indices = []; + // HACK: we bind an empty texture to avoid WebGL warning spam. + var tempTexture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, 1, 1, 0, gl.RGB, gl.UNSIGNED_BYTE, null); for (var i = 0; i < this.MAX_TEXTURES; ++i) { + gl.activeTexture(gl.TEXTURE0 + i); + gl.bindTexture(gl.TEXTURE_2D, tempTexture); indices.push(i); } - // NOTE:!!! - // If textures are not bound - // then we'll get a bunch of warnings like: - // "WARNING: there is no texture bound to the unit X" - // Don't be scared, everything will be alright. + gl.activeTexture(gl.TEXTURE0); gl.uniform1iv(this.uSampler, indices); this.projectionVector = gl.getUniformLocation(program, 'projectionVector'); diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 76b2ac930..7e6eb3a2e 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -225,10 +225,10 @@ PIXI.WebGLSpriteBatch.prototype.render = function (sprite, matrix) { var baseTexture = texture.baseTexture; var gl = this.gl; if (this.textureArray[baseTexture.textureIndex] != baseTexture) { + this.flush(); gl.activeTexture(gl.TEXTURE0 + baseTexture.textureIndex); gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id]); this.textureArray[baseTexture.textureIndex] = baseTexture; - this.flush(); } // They provided an alternative rendering matrix, so use it From 1e730e008dccb892121171f70cf7c376e19b0863 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 26 Jul 2016 15:12:21 +0100 Subject: [PATCH 04/33] Removed PolyK --- build/config.php | 1 - 1 file changed, 1 deletion(-) diff --git a/build/config.php b/build/config.php index 9ed3ad358..5bfc5a3e5 100644 --- a/build/config.php +++ b/build/config.php @@ -54,7 +54,6 @@ - From e15d98e34bedf7900d8aaa8eb86c9a2e5455ada4 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 26 Jul 2016 17:07:16 +0100 Subject: [PATCH 05/33] Removed Polyk. --- tasks/manifests/graphics.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/manifests/graphics.json b/tasks/manifests/graphics.json index 454cb74d8..ce8574c84 100644 --- a/tasks/manifests/graphics.json +++ b/tasks/manifests/graphics.json @@ -1,7 +1,6 @@ [ "src/pixi/primitives/Graphics.js", "src/pixi/primitives/GraphicsData.js", - "src/pixi/utils/Polyk.js", "src/pixi/utils/EarCut.js", "src/pixi/renderers/webgl/utils/WebGLGraphics.js", "src/pixi/renderers/canvas/CanvasGraphics.js", From 1711266ff857331e7b27753b2227fd21f95ad807 Mon Sep 17 00:00:00 2001 From: Felipe Alfonso Date: Wed, 27 Jul 2016 00:36:20 -0400 Subject: [PATCH 06/33] Fixed multi texture support on tiling sprite. --- src/pixi/extras/TilingSprite.js | 5 +++-- src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js | 14 +++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index 5de425285..6d3c41f8b 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -180,6 +180,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession) { if (this.tilingTexture.needsUpdate) { + this.tilingTexture.baseTexture.textureIndex = this.texture.baseTexture.textureIndex; renderSession.renderer.updateTexture(this.tilingTexture.baseTexture); this.tilingTexture.needsUpdate = false; } @@ -197,7 +198,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession) this.children[i]._renderWebGL(renderSession); } - renderSession.spriteBatch.stop(); + //renderSession.spriteBatch.stop(); if (this._filters) { @@ -209,7 +210,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession) renderSession.maskManager.popMask(this._mask, renderSession); } - renderSession.spriteBatch.start(); + //renderSession.spriteBatch.start(); }; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 7e6eb3a2e..539343c18 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -362,12 +362,12 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function (sprite) { var texture = sprite.tilingTexture; var baseTexture = texture.baseTexture; var gl = this.gl; - - if (this.textureArray[baseTexture.textureIndex] != baseTexture) { - gl.activeTexture(gl.TEXTURE0 + baseTexture.textureIndex); - gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id]); - this.textureArray[baseTexture.textureIndex] = baseTexture; + var textureIndex = sprite.texture.baseTexture.textureIndex; + if (this.textureArray[textureIndex] != baseTexture) { this.flush(); + gl.activeTexture(gl.TEXTURE0 + textureIndex); + gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id]); + this.textureArray[textureIndex] = baseTexture; } // check texture.. @@ -444,7 +444,6 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function (sprite) { var d = wt.d / resolution; var tx = wt.tx; var ty = wt.ty; - var textureIndex = texture.baseTexture.textureIndex; // xy positions[i++] = a * w1 + c * h1 + tx; positions[i++] = d * h1 + b * w1 + ty; @@ -651,9 +650,6 @@ PIXI.WebGLSpriteBatch.prototype.renderBatch = function (texture, size, startInde // If updateTexture returns false then we cannot render it, so bail out now return; } - } else { - gl.activeTexture(gl.TEXTURE0 + texture.textureIndex); - gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]); } gl.drawElements(gl.TRIANGLES, size * 6, gl.UNSIGNED_SHORT, startIndex * 6 * 2); // increment the draw count From f68f454620d46a4a2cc077da7d79db553945fd57 Mon Sep 17 00:00:00 2001 From: Felipe Alfonso Date: Wed, 27 Jul 2016 12:49:42 -0400 Subject: [PATCH 07/33] Fix Tiling Sprite mask and filter --- src/pixi/extras/TilingSprite.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pixi/extras/TilingSprite.js b/src/pixi/extras/TilingSprite.js index 6d3c41f8b..e3cb6f8a0 100644 --- a/src/pixi/extras/TilingSprite.js +++ b/src/pixi/extras/TilingSprite.js @@ -197,21 +197,23 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession) { this.children[i]._renderWebGL(renderSession); } - - //renderSession.spriteBatch.stop(); - + var restartBatch = false; if (this._filters) { + restartBatch = true; + renderSession.spriteBatch.stop(); renderSession.filterManager.popFilter(); } if (this._mask) { + if (!restartBatch) + renderSession.spriteBatch.stop(); renderSession.maskManager.popMask(this._mask, renderSession); } + if (restartBatch) + renderSession.spriteBatch.start(); - //renderSession.spriteBatch.start(); - }; /** From 7b4d6a65ca0325181d0d54aae96e05fa775add0a Mon Sep 17 00:00:00 2001 From: Filip Nedyalkov Date: Thu, 28 Jul 2016 21:41:34 +0300 Subject: [PATCH 08/33] fixed getLocalBounds() to return the bounds of the DisplayObject without transformations and adjusted width and height to work the way they did before to be compatible with how PIXI used to work. --- src/pixi/display/DisplayObjectContainer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 9d4098b11..25c66c503 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -435,14 +435,14 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function (targetCoordinateSpac }; /** - * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle. The calculation takes all visible children into consideration. + * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration. * * @method getLocalBounds * @return {Rectangle} The rectangular bounding area */ PIXI.DisplayObjectContainer.prototype.getLocalBounds = function () { - return this.getBounds(this.parent); + return this.getBounds(this); }; @@ -577,7 +577,7 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function (renderSession) { Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', { get: function() { - return this.getLocalBounds().width; + return this.getLocalBounds().width + this.scale.x; }, set: function(value) { @@ -606,7 +606,7 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', { Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', { get: function() { - return this.getLocalBounds().height; + return this.getLocalBounds().height * this.scale.y; }, set: function(value) { From a3502ebb4f414b3e753e5c27dd5ae01a9759b999 Mon Sep 17 00:00:00 2001 From: Filip Nedyalkov Date: Thu, 28 Jul 2016 21:47:21 +0300 Subject: [PATCH 09/33] updated the comment for getLocalBounds() in the typescript definitions. --- typescript/pixi.comments.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/pixi.comments.d.ts b/typescript/pixi.comments.d.ts index 2f7de9b3f..864bae91c 100644 --- a/typescript/pixi.comments.d.ts +++ b/typescript/pixi.comments.d.ts @@ -901,7 +901,7 @@ declare module PIXI { getChildIndex(child: DisplayObject): number; /** - * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle. The calculation takes all visible children into consideration. + * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration. * @return The rectangular bounding area */ getLocalBounds(): Rectangle; From 24368ef8d78b8faef60232b78be40e81aae3c050 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jul 2016 03:39:04 +0100 Subject: [PATCH 10/33] Docs update. --- src/loader/Loader.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/loader/Loader.js b/src/loader/Loader.js index 1608f31fd..fff453e44 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -1165,6 +1165,10 @@ Phaser.Loader.prototype = { /** * Adds a Tile Map data file to the current load queue. * + * Phaser can load data in two different formats: CSV and Tiled JSON. + * + * Tiled is a free software package, specifically for creating tilemaps, and is available from http://www.mapeditor.org + * * You can choose to either load the data externally, by providing a URL to a json file. * Or you can pass in a JSON object or String via the `data` parameter. * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache. From fb5ba0aa6226ce829ef5e103fb851ab88161a3e1 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jul 2016 03:39:21 +0100 Subject: [PATCH 11/33] Bail out if no parent. --- src/pixi/display/DisplayObject.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 018646003..fa121f75c 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -644,16 +644,24 @@ Object.defineProperties(PIXI.DisplayObject.prototype, { { var item = this.parent; - do + if (!item) { - if (!item.visible) - { - return false; - } - - item = item.parent; + return this.visible; + } + else + { + do + { + if (!item.visible) + { + return false; + } + + item = item.parent; + } + while (item); + } - while (item); return true; } From 3c3d09e46a091d728e608bdcba9d6926be2aa841 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jul 2016 03:39:34 +0100 Subject: [PATCH 12/33] Docs update. --- src/tilemap/Tilemap.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index dba6e63c7..b45575198 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -6,6 +6,9 @@ /** * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file. +* +* Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org +* * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key. * When using CSV data you must provide the key and the tileWidth and tileHeight parameters. * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here. From 688752c5dee42702ad36deab68fdddf39e86cc06 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jul 2016 03:39:39 +0100 Subject: [PATCH 13/33] Math.getShortestAngle will return the shortest angle between the two given angles. Angles are in the range -180 to 180, which is what `Sprite.angle` uses. So you can happily feed this method two sprite angles, and get the shortest angle back between them (#2494) --- README.md | 1 + src/math/Math.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index bf0c4888f..683bafaa5 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Group.iterate has a new `returnType`: `RETURN_ALL`. This allows you to return all children that pass the iteration test in an array. * The property `checkCollision.none` in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the `separate` method. By setting `checkCollision.none = true` you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661) * Math.rotateToAngle takes two angles (in radians), and an interpolation value, and returns a new angle, based on the shortest rotational distance between the two. +* Math.getShortestAngle will return the shortest angle between the two given angles. Angles are in the range -180 to 180, which is what `Sprite.angle` uses. So you can happily feed this method two sprite angles, and get the shortest angle back between them (#2494) ### Updates diff --git a/src/math/Math.js b/src/math/Math.js index 30f1c55a3..9ca7179f1 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -371,6 +371,30 @@ Phaser.Math = { }, + /** + * Gets the shortest angle between `angle1` and `angle2`. + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method, and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * less than 0 then it's a counter-clockwise rotation, if >= 0 then it's + * a clockwise rotation. + * + * @method Phaser.Math#getShortestAngle + * @param {number} angle1 - The first angle. In the range -180 to 180. + * @param {number} angle2 - The second angle. In the range -180 to 180. + * @return {number} The shortest angle, in degrees. If less than zero it's counter-clockwise, otherwise clockwise. + */ + getShortestAngle: function (angle1, angle2) { + + var difference = angle2 - angle1; + var times = Math.floor((difference - (-180)) / 360); + + return (difference - (times * 360)) * -1; + + }, + /** * Find the angle of a segment from (x1, y1) -> (x2, y2). * From a532f7b2c4bcfa0d9c91d4c43c104076f6a6e01b Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 29 Jul 2016 03:58:25 +0100 Subject: [PATCH 14/33] Optimised Math.getShortestAngle. --- src/math/Math.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/math/Math.js b/src/math/Math.js index 9ca7179f1..f24aab113 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -378,20 +378,26 @@ Phaser.Math = { * this method, and get the shortest angle back between the two of them. * * The angle returned will be in the same range. If the returned angle is - * less than 0 then it's a counter-clockwise rotation, if >= 0 then it's + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's * a clockwise rotation. * * @method Phaser.Math#getShortestAngle * @param {number} angle1 - The first angle. In the range -180 to 180. * @param {number} angle2 - The second angle. In the range -180 to 180. - * @return {number} The shortest angle, in degrees. If less than zero it's counter-clockwise, otherwise clockwise. + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. */ getShortestAngle: function (angle1, angle2) { var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + var times = Math.floor((difference - (-180)) / 360); - return (difference - (times * 360)) * -1; + return difference - (times * 360); }, From aad2ab398a4488c30ac837bd203186a66112889a Mon Sep 17 00:00:00 2001 From: Filip Nedyalkov Date: Fri, 29 Jul 2016 20:06:06 +0300 Subject: [PATCH 15/33] fixed a typo; --- src/pixi/display/DisplayObjectContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 25c66c503..f458166f2 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -577,7 +577,7 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function (renderSession) { Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', { get: function() { - return this.getLocalBounds().width + this.scale.x; + return this.getLocalBounds().width * this.scale.x; }, set: function(value) { From 64a02ddef4809c8ea485536a610df5e96cb808da Mon Sep 17 00:00:00 2001 From: Filip Nedyalkov Date: Tue, 2 Aug 2016 17:47:35 +0300 Subject: [PATCH 16/33] fixed top, bottom, left, right, centerX and centerY to use the updated getBounds and compute their values depending on the parent local coordinate space. I think this is better than using the global getBounds and a lot more convenient because it makes total sense x and centerX for example to be from the same coordinate space and also with this change now these values would be working when the group is a top level display object and also when it is parented by something else. So this loosens the global only getBounds restriction. Also it doesn't really makes sense to align objects with totally different parents but if that is the case separate calculations could be made. --- src/core/Group.js | 54 +++++++++++------------------------------------ 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/src/core/Group.js b/src/core/Group.js index 0a6a82089..7ad260151 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -2711,11 +2711,6 @@ Object.defineProperty(Phaser.Group.prototype, "angle", { * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. * -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. -* * @name Phaser.Group#centerX * @property {number} centerX */ @@ -2723,13 +2718,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", { get: function () { - return this.getBounds().centerX; + return this.getBounds(this.parent).centerX; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.x - r.x; this.x = (value + offset) - r.halfWidth; @@ -2744,11 +2739,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", { * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. * -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. -* * @name Phaser.Group#centerY * @property {number} centerY */ @@ -2756,13 +2746,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", { get: function () { - return this.getBounds().centerY; + return this.getBounds(this.parent).centerY; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.y - r.y; this.y = (value + offset) - r.halfHeight; @@ -2777,11 +2767,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", { * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. * -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. -* * @name Phaser.Group#left * @property {number} left */ @@ -2789,13 +2774,13 @@ Object.defineProperty(Phaser.Group.prototype, "left", { get: function () { - return this.getBounds().left; + return this.getBounds(this.parent).left; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.x - r.x; this.x = value + offset; @@ -2809,11 +2794,6 @@ Object.defineProperty(Phaser.Group.prototype, "left", { * * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. -* -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. * * @name Phaser.Group#right * @property {number} right @@ -2822,13 +2802,13 @@ Object.defineProperty(Phaser.Group.prototype, "right", { get: function () { - return this.getBounds().right; + return this.getBounds(this.parent).right; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.x - r.x; this.x = (value + offset) - r.width; @@ -2842,11 +2822,6 @@ Object.defineProperty(Phaser.Group.prototype, "right", { * * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. -* -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. * * @name Phaser.Group#top * @property {number} top @@ -2855,13 +2830,13 @@ Object.defineProperty(Phaser.Group.prototype, "top", { get: function () { - return this.getBounds().top; + return this.getBounds(this.parent).top; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.y - r.y; this.y = (value + offset); @@ -2876,11 +2851,6 @@ Object.defineProperty(Phaser.Group.prototype, "top", { * It is derived by calling `getBounds`, calculating the Groups dimensions based on its * visible children. * -* Note that no ancestors are factored into the result, meaning that if this Group is -* nested within another Group, with heavy transforms on it, the result of this property -* is likely to be incorrect. It is safe to get and set this property if the Group is a -* top-level descendant of Phaser.World, or untransformed parents. -* * @name Phaser.Group#bottom * @property {number} bottom */ @@ -2888,13 +2858,13 @@ Object.defineProperty(Phaser.Group.prototype, "bottom", { get: function () { - return this.getBounds().bottom; + return this.getBounds(this.parent).bottom; }, set: function (value) { - var r = this.getBounds(); + var r = this.getBounds(this.parent); var offset = this.y - r.y; this.y = (value + offset) - r.height; From e955cf42222e3d76e013e901fc32efc330675ac9 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 3 Aug 2016 04:04:22 +0100 Subject: [PATCH 17/33] Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing. --- README.md | 1 + src/sound/Sound.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 683bafaa5..dbdc9b8aa 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Weapon.autofire wouldn't fire after the first bullet, or until `fire` was called, neither of which are requirements. If you now set this boolean the Weapon will fire continuously until you toggle it back to false (thanks @alverLopez #2647) * ArcadePhysics.World.angleBetweenCenters now uses `centerX` and `centerY` properties to check for the angle between, instead of `center.x/y` as that property no longer exists (thanks @leopoldobrines7 #2654) * The Emitter.makeParticles `collide` argument didn't work, as a result of #2661, but is now properly respected thanks to that change (thanks @samme #2662) +* Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing. ### Pixi Updates diff --git a/src/sound/Sound.js b/src/sound/Sound.js index dd18759c6..0630a479b 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -555,6 +555,8 @@ Phaser.Sound.prototype = { this._sound.pause(); this._sound.currentTime = 0; } + + this.isPlaying = false; } if (marker === '' && Object.keys(this.markers).length > 0) @@ -566,10 +568,10 @@ Phaser.Sound.prototype = { if (marker !== '') { - this.currentMarker = marker; - if (this.markers[marker]) { + this.currentMarker = marker; + // Playing a marker? Then we default to the marker values this.position = this.markers[marker].start; this.volume = this.markers[marker].volume; @@ -594,7 +596,7 @@ Phaser.Sound.prototype = { } else { - // console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist"); + console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist"); return this; } } From a0c6ae6c51250e59b153f6abafd477766618d56f Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 3 Aug 2016 05:00:09 +0100 Subject: [PATCH 18/33] Phaser.Image now has the ScaleMinMax component. --- README.md | 2 +- src/gameobjects/Image.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dbdc9b8aa..75928b89a 100644 --- a/README.md +++ b/README.md @@ -331,7 +331,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Phaser.Tileset has a new property `lastgid` which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset. * Stage will now check if `document.hidden` is available first, and if it is then never even check for the prefixed versions. This stops warnings like "mozHidden and mozVisibilityState are deprecated" in newer versions of browsers and retain backward compatibility (thanks @leopoldobrines7 #2656) * As a result of changes in #2573 Graphics objects were calling `updateLocalBounds` on any shape change, which could cause dramatic performances drops in Graphics heavy situations (#2618). Graphics objects now have a new flag `_boundsDirty` which is used to detect if the bounds have been invalidated, i.e. by a Graphics being cleared or drawn to. If this is set to true then `updateLocalBounds` is called once in the `postUpdate` method (thanks @pengchuan #2618) - +* Phaser.Image now has the ScaleMinMax component. ### Bug Fixes diff --git a/src/gameobjects/Image.js b/src/gameobjects/Image.js index 5e5fb3841..1a6f9e630 100644 --- a/src/gameobjects/Image.js +++ b/src/gameobjects/Image.js @@ -24,6 +24,7 @@ * @extends Phaser.Component.LoadTexture * @extends Phaser.Component.Overlap * @extends Phaser.Component.Reset +* @extends Phaser.Component.ScaleMinMax * @extends Phaser.Component.Smoothed * @constructor * @param {Phaser.Game} game - A reference to the currently running game. @@ -68,6 +69,7 @@ Phaser.Component.Core.install.call(Phaser.Image.prototype, [ 'LoadTexture', 'Overlap', 'Reset', + 'ScaleMinMax', 'Smoothed' ]); From 906e00cec120573edd786ec4f02412e051a804f4 Mon Sep 17 00:00:00 2001 From: pjbaron Date: Mon, 8 Aug 2016 11:14:57 +1200 Subject: [PATCH 19/33] Minor optimisation and clean up. --- src/tilemap/TilemapLayerGL.js | 15 +++++++++------ src/tilemap/Tileset.js | 22 +++++++--------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/tilemap/TilemapLayerGL.js b/src/tilemap/TilemapLayerGL.js index 15baca432..4c7b8b601 100644 --- a/src/tilemap/TilemapLayerGL.js +++ b/src/tilemap/TilemapLayerGL.js @@ -464,12 +464,14 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left, // x/y - is cell location, normalized [0..width/height) in loop // xmax/ymax - remaining cells to render on column/row var tx, ty, x, y, xmax, ymax; + var tileset = this._mc.tileset; for (y = normStartY, ymax = bottom - top, ty = baseY; ymax >= 0; y++, ymax--, ty += th) { if (y >= height) { - y -= height; + // wrap around if coordinates go out of range 0..height + y %= height; } var row = this.layer.data[y]; @@ -478,7 +480,8 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left, { if (x >= width) { - x -= width; + // wrap around if coordinates go out of range 0..width + x %= width; } var tile = row[x]; @@ -487,23 +490,23 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left, if (!tile || tile.index < this._mc.tileset.firstgid || tile.index > this._mc.lastgid) { // skipping some tiles, add a degenerate marker into the batch list - this._mc.tileset.addDegenerate(this.glBatch); + tileset.addDegenerate(this.glBatch); continue; } var index = tile.index; - this._mc.tileset.drawGl(this.glBatch, tx + offx, ty + offy, index, tile.alpha, tile.flippedVal); + tileset.drawGl(this.glBatch, tx + offx, ty + offy, index, tile.alpha, tile.flippedVal); } // at end of each row, add a degenerate marker into the batch drawing list - this._mc.tileset.addDegenerate(this.glBatch); + tileset.addDegenerate(this.glBatch); } }; /** -* Clear and render the entire canvas. +* Render the entire visible region of the map. * * @method Phaser.TilemapLayerGL#renderFull * @private diff --git a/src/tilemap/Tileset.js b/src/tilemap/Tileset.js index 3849e8654..a77c642db 100644 --- a/src/tilemap/Tileset.js +++ b/src/tilemap/Tileset.js @@ -39,14 +39,6 @@ Phaser.Tileset = function (name, firstgid, width, height, margin, spacing, prope */ this.firstgid = firstgid | 0; - /** - * This is the ending index of the last tile index this Tileset can contain. - * This is populated automatically by Phaser.TilemapParser.parseTiledJSON. - * For a single tileset map it should be left as the default value. - * @property {integer} lastgid - */ - this.lastgid = Infinity; - /** * The width of each tile (in pixels). * @property {integer} tileWidth @@ -162,10 +154,10 @@ Phaser.Tileset.prototype = { }, /** - * Sets the GL Batch data to draw a tile from this Tileset at the given coordinates - * using a WebGL renderer. + * Draws a tile from this Tileset at the given coordinates using a WebGL renderer. * * @method Phaser.Tileset#drawGl + * @public * @param {Array} glBatch - A list of WebGL batch objects to draw later. * @param {number} x - The x coordinate to draw to. * @param {number} y - The y coordinate to draw to. @@ -230,16 +222,16 @@ Phaser.Tileset.prototype = { }, /** - * Adds a marker for the WebGL batch display to insert a degenerate - * triangle (eg. at the end of each row of tiles) + * Adds a marker for the WebGl batch display to insert a degenerate triangle (eg. at the end of each row of tiles) * * @method Phaser.Tileset#addDegenerate - * @param {array} glBatch - The GL Batch data array. + * @public + * @param {[type]} glBatch [description] */ addDegenerate: function (glBatch) { - // Don't insert multiple degenerate markers in a row - if (glBatch[glBatch.length - 1]) + // don't insert multiple degenerate markers in a row + if (glBatch.length > 0 && glBatch[glBatch.length - 1]) { glBatch.push(null); } From 68fe8b80585351e0c1d147b07f5448a869c406bc Mon Sep 17 00:00:00 2001 From: Sergey Z Date: Mon, 8 Aug 2016 16:51:07 +0300 Subject: [PATCH 20/33] Fix rendering text with bounds and resolution --- src/gameobjects/Text.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 6104ec9c8..a35b557a8 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -1442,20 +1442,20 @@ Phaser.Text.prototype.updateTexture = function () { // Align the canvas based on the bounds if (this.style.boundsAlignH === 'right') { - x += this.textBounds.width - this.canvas.width; + x += this.textBounds.width - this.canvas.width / this.resolution; } else if (this.style.boundsAlignH === 'center') { - x += this.textBounds.halfWidth - (this.canvas.width / 2); + x += this.textBounds.halfWidth - (this.canvas.width / this.resolution / 2); } if (this.style.boundsAlignV === 'bottom') { - y += this.textBounds.height - this.canvas.height; + y += this.textBounds.height - this.canvas.height / this.resolution; } else if (this.style.boundsAlignV === 'middle') { - y += this.textBounds.halfHeight - (this.canvas.height / 2); + y += this.textBounds.halfHeight - (this.canvas.height / this.resolution / 2); } this.pivot.x = -x; From 7afd442bce5d8ee3cf99a73bf5e8a45c3eed9c05 Mon Sep 17 00:00:00 2001 From: Ale Bles Date: Tue, 9 Aug 2016 10:11:39 +0200 Subject: [PATCH 21/33] Updated tutorial to fix #2642 Tutorial was missing a tiny piece of code that was found in the parts --- .../tutorials/02 Making your first game/tutorial.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/tutorials/02 Making your first game/tutorial.html b/resources/tutorials/02 Making your first game/tutorial.html index 447f911bd..4a6c18849 100644 --- a/resources/tutorials/02 Making your first game/tutorial.html +++ b/resources/tutorials/02 Making your first game/tutorial.html @@ -240,7 +240,12 @@ The final part of the code adds the ability to jump. The up cursor is our jump k It's time to give our little game a purpose. Let's drop a sprinkling of stars into the scene and allow the player to collect them. To achieve this we'll create a new Group called 'stars' and populate it. In our create function we add the following code (this can be seen in part8.html): -
    stars = game.add.group();
+
+    //  Finally some stars to collect
+    stars = game.add.group();
+
+    //  We will enable physics for any star that is created in this group
+    stars.enableBody = true;
 
     //  Here we'll create 12 of them evenly spaced apart
     for (var i = 0; i < 12; i++)

From e30ade0a6776e9ec36f4c05d05231ac7130766ad Mon Sep 17 00:00:00 2001
From: Chris Andrew 
Date: Mon, 15 Aug 2016 14:46:05 +0100
Subject: [PATCH 22/33] Fixed incorrectly parsing widthInPixels/heightInPixels
 for JSON tilemaps.

---
 src/tilemap/TilemapParser.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js
index 541393ee0..7b999c938 100644
--- a/src/tilemap/TilemapParser.js
+++ b/src/tilemap/TilemapParser.js
@@ -201,8 +201,8 @@ Phaser.TilemapParser = {
             format: Phaser.Tilemap.TILED_JSON,
             version: json.version,
             properties: json.properties,
-            widthInPixels: json.width * json.tileWidth,
-            heightInPixels: json.height * json.tileHeight
+            widthInPixels: json.width * json.tilewidth,
+            heightInPixels: json.height * json.tileheight
         };
 
         //  Tile Layers

From 50fc2cf0c38b169a7d7ba0e8eefd101df79be1f6 Mon Sep 17 00:00:00 2001
From: Chris Andrew 
Date: Mon, 15 Aug 2016 14:56:07 +0100
Subject: [PATCH 23/33] Fixed TilemapLayerGL bugs regarding display width and
 height.

---
 src/tilemap/TilemapLayerGL.js | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/tilemap/TilemapLayerGL.js b/src/tilemap/TilemapLayerGL.js
index 4c7b8b601..0ab08e3bf 100644
--- a/src/tilemap/TilemapLayerGL.js
+++ b/src/tilemap/TilemapLayerGL.js
@@ -337,8 +337,8 @@ Phaser.TilemapLayerGL.prototype.destroy = function() {
 Phaser.TilemapLayerGL.prototype.resize = function (width, height) {
 
     //  These setters will automatically update any linked children
-    this.displayWidth = width;
-    this.displayHeight = height;
+    this.width = width;
+    this.height = height;
 
     this.dirty = true;
 
@@ -512,16 +512,12 @@ Phaser.TilemapLayerGL.prototype.renderRegion = function (scrollX, scrollY, left,
 * @private
 */
 Phaser.TilemapLayerGL.prototype.renderFull = function () {
-    
+
     var scrollX = this._mc.scrollX;
     var scrollY = this._mc.scrollY;
 
-    // var renderW = this.game._width;
-    // var renderH = this.game._height;
-
-    //  displayWidth surely?
-    var renderW = this.game._width;
-    var renderH = this.game._height;
+    var renderW = this._displayWidth;
+    var renderH = this._displayHeight;
 
     var tw = this._mc.tileWidth;
     var th = this._mc.tileHeight;

From 49e40fc2d46aeb689dd7b112df4bf9ce74398026 Mon Sep 17 00:00:00 2001
From: Richard Davey 
Date: Tue, 16 Aug 2016 20:59:53 +0100
Subject: [PATCH 24/33] Typo

---
 src/gameobjects/Button.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js
index c362d974f..92097b2c0 100644
--- a/src/gameobjects/Button.js
+++ b/src/gameobjects/Button.js
@@ -173,7 +173,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
     this.onOverMouseOnly = true;
 
     /**
-    * Suppresse the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
+    * Suppress the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
     *
     * This behavior was introduced in Phaser 2.3.1; this property is a soft-revert of the change.
     *

From 63ce6ae6c466036467c28a9c6ca016adc77e3bbd Mon Sep 17 00:00:00 2001
From: Richard Davey 
Date: Tue, 16 Aug 2016 21:01:41 +0100
Subject: [PATCH 25/33] Defs update #2689

---
 README.md              | 2 +-
 typescript/phaser.d.ts | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 75928b89a..493fcf33c 100644
--- a/README.md
+++ b/README.md
@@ -319,7 +319,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
 
 ### Updates
 
-* TypeScript definitions fixes and updates (thanks @calvindavis)
+* TypeScript definitions fixes and updates (thanks @calvindavis @AlvaroBarua)
 * Docs typo fixes (thanks @rroylance @Owumaro @boniatillo-com)
 * The InputHandler.flagged property has been removed. It was never used internally, or exposed via the API, so was just overhead.
 * The src/system folder has been removed and all files relocated to the src/utils folder. This doesn't change anything from an API point of view, but did change the grunt build scripts slightly.
diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts
index 8e668ffc7..9a7d5acd0 100644
--- a/typescript/phaser.d.ts
+++ b/typescript/phaser.d.ts
@@ -1401,6 +1401,7 @@ declare module Phaser {
         physicsConfig?: any;
         seed?: string;
         state?: Phaser.State;
+        forceSetTimeOut: boolean;
 
     }
 

From 8d69d0e2e8457444419aae0a12a438eb59538559 Mon Sep 17 00:00:00 2001
From: Richard Davey 
Date: Tue, 16 Aug 2016 21:12:03 +0100
Subject: [PATCH 26/33] Docs update.

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 493fcf33c..3f3a7da83 100644
--- a/README.md
+++ b/README.md
@@ -332,6 +332,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
 * Stage will now check if `document.hidden` is available first, and if it is then never even check for the prefixed versions. This stops warnings like "mozHidden and mozVisibilityState are deprecated" in newer versions of browsers and retain backward compatibility (thanks @leopoldobrines7 #2656)
 * As a result of changes in #2573 Graphics objects were calling `updateLocalBounds` on any shape change, which could cause dramatic performances drops in Graphics heavy situations (#2618). Graphics objects now have a new flag `_boundsDirty` which is used to detect if the bounds have been invalidated, i.e. by a Graphics being cleared or drawn to. If this is set to true then `updateLocalBounds` is called once in the `postUpdate` method (thanks @pengchuan #2618)
 * Phaser.Image now has the ScaleMinMax component.
+* Animations now allow for speeds greater than 0, rather than forcing them to be greater than 1. This allows you to have animation speeds slower than 1 frame per second (thanks @jayrobin #2664)
 
 ### Bug Fixes
 

From 129a652f07ffe1f35003370ea3f4de78375c9885 Mon Sep 17 00:00:00 2001
From: Richard Davey 
Date: Wed, 17 Aug 2016 00:38:43 +0100
Subject: [PATCH 27/33] Docs update.

---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 3f3a7da83..64db9e70e 100644
--- a/README.md
+++ b/README.md
@@ -341,6 +341,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
 * ArcadePhysics.World.angleBetweenCenters now uses `centerX` and `centerY` properties to check for the angle between, instead of `center.x/y` as that property no longer exists (thanks @leopoldobrines7 #2654)
 * The Emitter.makeParticles `collide` argument didn't work, as a result of #2661, but is now properly respected thanks to that change (thanks @samme #2662)
 * Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing.
+* Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685)
+* TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691)
 
 ### Pixi Updates
 

From bfb12d9dba2416e8a0207e225ee0370ccc90eb59 Mon Sep 17 00:00:00 2001
From: photonstorm 
Date: Wed, 17 Aug 2016 11:28:03 +0100
Subject: [PATCH 28/33] Fixed code formatting.

---
 src/animation/Animation.js        | 30 +++++++++++++++++-------------
 src/animation/AnimationManager.js |  3 ---
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/animation/Animation.js b/src/animation/Animation.js
index dce6aa9c6..85cb111fc 100644
--- a/src/animation/Animation.js
+++ b/src/animation/Animation.js
@@ -244,29 +244,33 @@ Phaser.Animation.prototype = {
     },
 
     /**
-     * Reverses the animation direction
-     *
-     * @method Phaser.Animation#reverse
-     * @return {Phaser.Animation} The animation instance.
-     * */
+    * 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.
-     * */
+    * 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));
+
+        this.onComplete.addOnce(this.reverse, this);
 
         return this.reverse();
+
     },
 
     /**
diff --git a/src/animation/AnimationManager.js b/src/animation/AnimationManager.js
index db8ee0c9b..2157abcbe 100644
--- a/src/animation/AnimationManager.js
+++ b/src/animation/AnimationManager.js
@@ -207,9 +207,6 @@ Phaser.AnimationManager.prototype = {
 
         this.currentAnim = this._anims[name];
 
-        //  This shouldn't be set until the Animation is played, surely?
-        // this.currentFrame = this.currentAnim.currentFrame;
-
         if (this.sprite.tilingTexture)
         {
             this.sprite.refreshTexture = true;

From e90619b40eaf9cb8a24507b58940c1ab7ba3641b Mon Sep 17 00:00:00 2001
From: James 
Date: Wed, 17 Aug 2016 18:24:24 -0500
Subject: [PATCH 29/33] changed return value of Plugin.Weapon's fire, fireAtXY,
 fireAtPointer, fireAtSprite to Phaser.Bullet

---
 src/plugins/weapon/WeaponPlugin.js | 10 +++++-----
 typescript/phaser.d.ts             | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/plugins/weapon/WeaponPlugin.js b/src/plugins/weapon/WeaponPlugin.js
index d7cccfff4..5b074e754 100644
--- a/src/plugins/weapon/WeaponPlugin.js
+++ b/src/plugins/weapon/WeaponPlugin.js
@@ -699,7 +699,7 @@ Phaser.Weapon.prototype.trackPointer = function (pointer, offsetX, offsetY) {
 * @param {Phaser.Sprite|Phaser.Point|Object} [from] - Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides `Weapon.trackedSprite` or `trackedPointer`. Pass `null` to ignore it.
 * @param {number} [x] - The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
 * @param {number} [y] - The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
-* @return {boolean} True if a bullet was successfully fired, otherwise false.
+* @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
 */
 Phaser.Weapon.prototype.fire = function (from, x, y) {
 
@@ -880,7 +880,7 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
             this.onFireLimit.dispatch(this, this.fireLimit);
         }
     }
-
+    return bullet;
 };
 
 /**
@@ -889,7 +889,7 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
 *
 * @method Phaser.Weapon#fireAtPointer
 * @param {Phaser.Pointer} [pointer] - The Pointer to fire the bullet towards.
-* @return {boolean} True if a bullet was successfully fired, otherwise false.
+* @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
 */
 Phaser.Weapon.prototype.fireAtPointer = function (pointer) {
 
@@ -905,7 +905,7 @@ Phaser.Weapon.prototype.fireAtPointer = function (pointer) {
 *
 * @method Phaser.Weapon#fireAtSprite
 * @param {Phaser.Sprite} [sprite] - The Sprite to fire the bullet towards.
-* @return {boolean} True if a bullet was successfully fired, otherwise false.
+* @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
 */
 Phaser.Weapon.prototype.fireAtSprite = function (sprite) {
 
@@ -920,7 +920,7 @@ Phaser.Weapon.prototype.fireAtSprite = function (sprite) {
 * @method Phaser.Weapon#fireAtXY
 * @param {number} [x] - The x coordinate, in world space, to fire the bullet towards.
 * @param {number} [y] - The y coordinate, in world space, to fire the bullet towards.
-* @return {boolean} True if a bullet was successfully fired, otherwise false.
+* @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
 */
 Phaser.Weapon.prototype.fireAtXY = function (x, y) {
 
diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts
index 9a7d5acd0..51337298d 100644
--- a/typescript/phaser.d.ts
+++ b/typescript/phaser.d.ts
@@ -809,7 +809,7 @@ declare module Phaser {
         l: number;
         color: number;
         color32: number;
-        rgba: string;        
+        rgba: string;
     }
 
     class Create {
@@ -5651,10 +5651,10 @@ declare module Phaser {
         createBullets(quantity?: number, key?: any, frame?: any, group?: Phaser.Group): Phaser.Weapon;
         debug(x?: number, y?: number, debugBodies?: boolean): void;
         destroy(): void;
-        fire(from?: any, x?: number, y?: number): boolean;
-        fireAtPointer(pointer: Phaser.Pointer): boolean;
-        fireAtSprite(sprite: Phaser.Sprite): boolean;
-        fireAtXY(x: number, y: number): boolean;
+        fire(from?: any, x?: number, y?: number): Phaser.Bullet;
+        fireAtPointer(pointer: Phaser.Pointer): Phaser.Bullet;
+        fireAtSprite(sprite: Phaser.Sprite): Phaser.Bullet;
+        fireAtXY(x: number, y: number): Phaser.Bullet;
         forEach(callback: any, callbackContext: any): Phaser.Weapon;
         killAll(): Phaser.Weapon;
         pauseAll(): Phaser.Weapon;

From 067f3cca83a6dad1f6d928e474fbb18d65ea4681 Mon Sep 17 00:00:00 2001
From: Vaughan Hilts 
Date: Wed, 17 Aug 2016 22:12:22 -0400
Subject: [PATCH 30/33] Sound: Fixes an issue where loopFull would not return
 the soundinstance that it looped from

---
 src/sound/Sound.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sound/Sound.js b/src/sound/Sound.js
index 1fbc91d6f..64955a6c4 100644
--- a/src/sound/Sound.js
+++ b/src/sound/Sound.js
@@ -477,7 +477,7 @@ Phaser.Sound.prototype = {
      */
     loopFull: function (volume) {
 
-        this.play(null, 0, volume, true);
+       return this.play(null, 0, volume, true);
 
     },
 

From 04e70e820c062827eccb9934db6ceb39d571b2b3 Mon Sep 17 00:00:00 2001
From: photonstorm 
Date: Thu, 18 Aug 2016 15:35:35 +0100
Subject: [PATCH 31/33] Updated KeyCode docs placement #2653

---
 README.md                                           | 2 ++
 resources/docstrap-master/template/tmpl/layout.tmpl | 1 +
 src/input/Keyboard.js                               | 8 +++++---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 64db9e70e..1b872a63e 100644
--- a/README.md
+++ b/README.md
@@ -333,6 +333,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
 * As a result of changes in #2573 Graphics objects were calling `updateLocalBounds` on any shape change, which could cause dramatic performances drops in Graphics heavy situations (#2618). Graphics objects now have a new flag `_boundsDirty` which is used to detect if the bounds have been invalidated, i.e. by a Graphics being cleared or drawn to. If this is set to true then `updateLocalBounds` is called once in the `postUpdate` method (thanks @pengchuan #2618)
 * Phaser.Image now has the ScaleMinMax component.
 * Animations now allow for speeds greater than 0, rather than forcing them to be greater than 1. This allows you to have animation speeds slower than 1 frame per second (thanks @jayrobin #2664)
+* Weapon.fire and all related methods (fireAtXY, fireAtPointer, fireAtSprite) now all return the instance of the Phaser.Bullet that was fired, or `null` if nothing was fired. Previously it would return a boolean, but this change allows you to perform additional processing on the Bullet as required (thanks @JTronLabs #2696)
+* Sound.loopFull now returns the Sound instance that was looped (thanks @hilts-vaughan #2697)
 
 ### Bug Fixes
 
diff --git a/resources/docstrap-master/template/tmpl/layout.tmpl b/resources/docstrap-master/template/tmpl/layout.tmpl
index d43fba4cb..6d1c4b86d 100644
--- a/resources/docstrap-master/template/tmpl/layout.tmpl
+++ b/resources/docstrap-master/template/tmpl/layout.tmpl
@@ -128,6 +128,7 @@
 						
  • Mouse
  • Keyboard
  • Key
  • +
  • Key Codes
  • Gamepad
  • diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index 17effd234..5624dcd86 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -604,7 +604,7 @@ Phaser.Keyboard.prototype.constructor = Phaser.Keyboard; * _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code; * the latter approach is supported for compatibility. * -* @namespace +* @class Phaser.KeyCode */ Phaser.KeyCode = { /** @static */ @@ -814,8 +814,10 @@ Phaser.KeyCode = { }; // Duplicate Phaser.KeyCode values in Phaser.Keyboard for compatibility -for (var key in Phaser.KeyCode) { - if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/)) { +for (var key in Phaser.KeyCode) +{ + if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/)) + { Phaser.Keyboard[key] = Phaser.KeyCode[key]; } } From 4382944a2e310b6fc855842e8f490b25be117194 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 18 Aug 2016 15:55:13 +0100 Subject: [PATCH 32/33] A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688) --- README.md | 1 + src/gameobjects/components/Crop.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b872a63e..dd2198c01 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing. * Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685) * TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691) +* A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688) ### Pixi Updates diff --git a/src/gameobjects/components/Crop.js b/src/gameobjects/components/Crop.js index e55e0e15b..ce7049927 100644 --- a/src/gameobjects/components/Crop.js +++ b/src/gameobjects/components/Crop.js @@ -46,7 +46,7 @@ Phaser.Component.Crop.prototype = { * @param {Phaser.Rectangle} rect - The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle. * @param {boolean} [copy=false] - If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect. */ - crop: function(rect, copy) { + crop: function (rect, copy) { if (copy === undefined) { copy = false; } @@ -83,13 +83,18 @@ Phaser.Component.Crop.prototype = { * * @method */ - updateCrop: function() { + updateCrop: function () { if (!this.cropRect) { return; } + var oldX = this.texture.crop.x; + var oldY = this.texture.crop.y; + var oldW = this.texture.crop.width; + var oldH = this.texture.crop.height; + this._crop = Phaser.Rectangle.clone(this.cropRect, this._crop); this._crop.x += this._frame.x; this._crop.y += this._frame.y; @@ -112,6 +117,11 @@ Phaser.Component.Crop.prototype = { this.texture._updateUvs(); + if (this.tint !== 0xffffff && (oldX !== cx || oldY !== cy || oldW !== cw || oldH !== ch)) + { + this.texture.requiresReTint = true; + } + } }; From 19342fa3af4e793a2924d9bc8df430b1251142bb Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sun, 21 Aug 2016 10:27:58 +0100 Subject: [PATCH 33/33] ArcadePhysics Body.rotation now reads its initial value from sprite.angle instead of sprite.rotation. The property was immediately replaced with the correct value in Body.preUpdate regardless, but it keeps it consistent (thanks @samme #2708) --- README.md | 1 + src/physics/arcade/Body.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd2198c01..626daeea0 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Animations now allow for speeds greater than 0, rather than forcing them to be greater than 1. This allows you to have animation speeds slower than 1 frame per second (thanks @jayrobin #2664) * Weapon.fire and all related methods (fireAtXY, fireAtPointer, fireAtSprite) now all return the instance of the Phaser.Bullet that was fired, or `null` if nothing was fired. Previously it would return a boolean, but this change allows you to perform additional processing on the Bullet as required (thanks @JTronLabs #2696) * Sound.loopFull now returns the Sound instance that was looped (thanks @hilts-vaughan #2697) +* ArcadePhysics Body.rotation now reads its initial value from sprite.angle instead of sprite.rotation. The property was immediately replaced with the correct value in Body.preUpdate regardless, but it keeps it consistent (thanks @samme #2708) ### Bug Fixes diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 2efaa73c0..90db969f3 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -82,13 +82,13 @@ Phaser.Physics.Arcade.Body = function (sprite) { * itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation. * @property {number} rotation */ - this.rotation = sprite.rotation; + this.rotation = sprite.angle; /** * @property {number} preRotation - The previous rotation of the physics body. * @readonly */ - this.preRotation = sprite.rotation; + this.preRotation = sprite.angle; /** * @property {number} width - The calculated width of the physics body.