Skip to content

Commit

Permalink
Sprite.loadTexture will store the smoothed property of the Sprite a…
Browse files Browse the repository at this point in the history
…nd re-apply it once the new texture is loaded.
  • Loading branch information
photonstorm committed Jul 15, 2014
1 parent 90eec97 commit f6935c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions build/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand Down
15 changes: 9 additions & 6 deletions src/gameobjects/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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;
}

};
Expand Down

0 comments on commit f6935c0

Please sign in to comment.