Skip to content

Commit f6935c0

Browse files
committed
Sprite.loadTexture will store the smoothed property of the Sprite and re-apply it once the new texture is loaded.
1 parent 90eec97 commit f6935c0

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

build/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ declare module Phaser {
11261126
setFrame(frameId?: any, useLocalFrameIndex?: boolean): void;
11271127
stop(resetFrame?: boolean, dispatchComplete?: boolean): void;
11281128
update(): boolean;
1129+
updateFrameData(frameData: Phaser.FrameData): void;
11291130

11301131
}
11311132

src/gameobjects/Sprite.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,15 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) {
361361

362362
frame = frame || 0;
363363

364+
if (stopAnimation || typeof stopAnimation === 'undefined')
365+
{
366+
this.animations.stop();
367+
}
368+
364369
this.key = key;
365370

366371
var setFrame = true;
372+
var smoothed = this.smoothed;
367373

368374
if (key instanceof Phaser.RenderTexture)
369375
{
@@ -395,10 +401,7 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) {
395401
{
396402
this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[key]));
397403

398-
if (this.animations)
399-
{
400-
setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key), frame);
401-
}
404+
setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key), frame);
402405
}
403406
}
404407

@@ -407,9 +410,9 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame, stopAnimation) {
407410
this._frame = Phaser.Rectangle.clone(this.texture.frame);
408411
}
409412

410-
if (stopAnimation || typeof stopAnimation === 'undefined')
413+
if (!smoothed)
411414
{
412-
this.animations.stop();
415+
this.smoothed = false;
413416
}
414417

415418
};

0 commit comments

Comments
 (0)