Skip to content

Commit 90eec97

Browse files
committed
Animation.updateFrameData allows you to load a new FrameData object into an existing animation, even if currently running (based on phaserjs#1029)
AnimationManager.loadFrameData will now update all existing Animations to use the newly loaded FrameData (based on phaserjs#1029)
1 parent aaf82f9 commit 90eec97

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Version 2.0.7 - "Amadicia" - -in development-
6464

6565
* ArrayList.setAll - sets the property to the given value on all members of the list.
6666
* Sprite.loadTexture has a new optional `stopAnimation` boolean parameter which will halt the currently running animation (if any) after changing the texture (based on #1029).
67+
* Animation.updateFrameData allows you to load a new FrameData object into an existing animation, even if currently running (based on #1029)
68+
* AnimationManager.loadFrameData will now update all existing Animations to use the newly loaded FrameData (based on #1029)
69+
* Sprite.loadTexture will store the `smoothed` property of the Sprite and re-apply it once the new texture is loaded.
6770

6871
### Bug Fixes
6972

src/animation/Animation.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,19 @@ Phaser.Animation.prototype = {
501501

502502
},
503503

504+
/**
505+
* Changes the FrameData object this Animation is using.
506+
*
507+
* @method Phaser.Animation#updateFrameData
508+
* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
509+
*/
510+
updateFrameData: function (frameData) {
511+
512+
this._frameData = frameData;
513+
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
514+
515+
},
516+
504517
/**
505518
* Cleans up this animation ready for deletion. Nulls all values and references.
506519
*

src/animation/AnimationManager.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ Phaser.AnimationManager.prototype = {
8383
*/
8484
loadFrameData: function (frameData, frame) {
8585

86+
if (this.isLoaded)
87+
{
88+
// We need to update the frameData that the animations are using
89+
for (var anim in this._anims)
90+
{
91+
this._anims[anim].updateFrameData(frameData);
92+
}
93+
}
94+
8695
this._frameData = frameData;
8796

8897
if (typeof frame === 'undefined' || frame === null)

0 commit comments

Comments
 (0)