TileSprites that were set to be interactive before they had rendered once wouldn't receive a valid input hit area, causing input to fail. They now define their size immediately, allowing them to be made interactive without having rendered. Fix #4085

This commit is contained in:
Richard Davey 2018-10-05 16:27:42 +01:00
parent 2a1ea30cb7
commit 0f929bf0cc
2 changed files with 4 additions and 27 deletions

View file

@ -11,11 +11,13 @@
* `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process (thanks jamespierce)
* The `RequestAnimationFrame.step` and `stepTimeout` functions have been updated so that the new Frame is requested from raf before the main game step is called. This allows you to now stop the raf callback from within the game update or render loop. Fix #3952 (thanks @tolimeh)
* If you pass zero as the width or height when creating a TileSprite it will now use the dimensions of the texture frame as the size of the TileSprite. Fix #4073 (thanks @jcyuan)
* `TileSprite.setFrame` has had both the `updateSize` and `updateOrigin` arguments removed as they didn't do anything for TileSprites and were misleading.
### Bug Fixes
* Fixed a bug in the canvas rendering of both the Static and Dynamic Tilemap Layers where the camera matrix was being multiplied twice with the layer, causing the scale and placement to be off (thanks galerijanamar)
* If you set `pixelArt` to true in your game config (or `antialias` to false) then TileSprites will now respect this when using the Canvas Renderer and disable smoothing on the internal fill canvas.
* TileSprites that were set to be interactive before they had rendered once wouldn't receive a valid input hit area, causing input to fail. They now define their size immediately, allowing them to be made interactive without having rendered. Fix #4085 (thanks @DotTheGreat)
### Examples and TypeScript

View file

@ -271,9 +271,9 @@ var TileSprite = new Class({
*/
this.fillPattern = null;
this.setFrame(frameKey);
this.setPosition(x, y);
this.setSize(width, height);
this.setFrame(frameKey);
this.setOriginFromFrame();
this.initPipeline();
@ -317,23 +317,15 @@ var TileSprite = new Class({
*
* It can be either a string or an index.
*
* Calling `setFrame` will modify the `width` and `height` properties of your Game Object.
* It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer.
*
* @method Phaser.GameObjects.TileSprite#setFrame
* @since 3.0.0
*
* @param {(string|integer)} frame - The name or index of the frame within the Texture.
* @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object?
* @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object?
*
* @return {this} This Game Object instance.
*/
setFrame: function (frame, updateSize, updateOrigin)
setFrame: function (frame)
{
if (updateSize === undefined) { updateSize = true; }
if (updateOrigin === undefined) { updateOrigin = true; }
this.displayFrame = this.displayTexture.get(frame);
if (!this.displayFrame.cutWidth || !this.displayFrame.cutHeight)
@ -345,23 +337,6 @@ var TileSprite = new Class({
this.renderFlags |= _FLAG;
}
if (this._sizeComponent && updateSize)
{
this.setSizeToFrame();
}
if (this._originComponent && updateOrigin)
{
if (this.displayFrame.customPivot)
{
this.setOrigin(this.displayFrame.pivotX, this.displayFrame.pivotY);
}
else
{
this.updateDisplayOrigin();
}
}
this.dirty = true;
this.updateTileTexture();