Skip to content

Commit a5eacab

Browse files
committed
Allow for chaining multible animations
This allows for chaining multible animations by calling the chain(key) method multible times like this: this.mole.anims.play('digging',true).anims.chain('lifting').anims.chain('looking').anims.chain('lowering'); This commit adds a new property nextAnimsQueue. This is an array that holds the chained keys in order of chain() requests. This list will be worked on in the stop() function.
1 parent d6e8600 commit a5eacab

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/gameobjects/components/Animation.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ var Animation = new Class({
8787
*/
8888
this.nextAnim = null;
8989

90+
/**
91+
* A queue of chained keys of the next Animations to be loaded into this Animation Controller when the current animation completes.
92+
*
93+
* @name Phaser.GameObjects.Components.Animation#nextAnim
94+
* @type {Array}
95+
* @default []
96+
*/
97+
this.nextAnimsQueue = [];
98+
9099
/**
91100
* Time scale factor.
92101
*
@@ -321,7 +330,11 @@ var Animation = new Class({
321330
key = key.key;
322331
}
323332

324-
this.nextAnim = key;
333+
if(this.nextAnim === null){
334+
this.nextAnim = key;
335+
}else{
336+
this.nextAnimsQueue.push(key);
337+
}
325338

326339
return this.parent;
327340
},
@@ -850,7 +863,7 @@ var Animation = new Class({
850863
{
851864
var key = this.nextAnim;
852865

853-
this.nextAnim = null;
866+
this.nextAnim = this.nextAnimsQueue.length > 0 ? this.nextAnimsQueue.shift() : null;
854867

855868
this.play(key);
856869
}

0 commit comments

Comments
 (0)