Skip to content

Commit

Permalink
Animation.updateFrameData allows you to load a new FrameData object i…
Browse files Browse the repository at this point in the history
…nto 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)
  • Loading branch information
photonstorm committed Jul 15, 2014
1 parent aaf82f9 commit 90eec97
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Version 2.0.7 - "Amadicia" - -in development-

* ArrayList.setAll - sets the property to the given value on all members of the list.
* 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).
* Animation.updateFrameData allows you to load a new FrameData object into an existing animation, even if currently running (based on #1029)
* AnimationManager.loadFrameData will now update all existing Animations to use the newly loaded FrameData (based on #1029)
* Sprite.loadTexture will store the `smoothed` property of the Sprite and re-apply it once the new texture is loaded.

### Bug Fixes

Expand Down
13 changes: 13 additions & 0 deletions src/animation/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@ Phaser.Animation.prototype = {

},

/**
* Changes the FrameData object this Animation is using.
*
* @method Phaser.Animation#updateFrameData
* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
*/
updateFrameData: function (frameData) {

this._frameData = frameData;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);

},

/**
* Cleans up this animation ready for deletion. Nulls all values and references.
*
Expand Down
9 changes: 9 additions & 0 deletions src/animation/AnimationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ Phaser.AnimationManager.prototype = {
*/
loadFrameData: function (frameData, frame) {

if (this.isLoaded)
{
// We need to update the frameData that the animations are using
for (var anim in this._anims)
{
this._anims[anim].updateFrameData(frameData);
}
}

this._frameData = frameData;

if (typeof frame === 'undefined' || frame === null)
Expand Down

0 comments on commit 90eec97

Please sign in to comment.