From f6935c01f8871fd438d896fb8a88b7307efd9e2e Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 16 Jul 2014 00:56:26 +0100 Subject: [PATCH] Sprite.loadTexture will store the `smoothed` property of the Sprite and re-apply it once the new texture is loaded. --- build/phaser.d.ts | 1 + src/gameobjects/Sprite.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build/phaser.d.ts b/build/phaser.d.ts index e00778291d..477e3264ca 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -1126,6 +1126,7 @@ declare module Phaser { setFrame(frameId?: any, useLocalFrameIndex?: boolean): void; stop(resetFrame?: boolean, dispatchComplete?: boolean): void; update(): boolean; + updateFrameData(frameData: Phaser.FrameData): void; } diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 64d776e3ee..f390452a23 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -361,9 +361,15 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) { frame = frame || 0; + if (stopAnimation || typeof stopAnimation === 'undefined') + { + this.animations.stop(); + } + this.key = key; var setFrame = true; + var smoothed = this.smoothed; if (key instanceof Phaser.RenderTexture) { @@ -395,10 +401,7 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) { { this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[key])); - if (this.animations) - { - setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key), frame); - } + setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key), frame); } } @@ -407,9 +410,9 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) { this._frame = Phaser.Rectangle.clone(this.texture.frame); } - if (stopAnimation || typeof stopAnimation === 'undefined') + if (!smoothed) { - this.animations.stop(); + this.smoothed = false; } };