Skip to content

Commit a391998

Browse files
committed
Allow chaining of multible animations
With this commit it is possible to chain more than one animation together for example: this.mole.anims.play('digging',true).anims.chain('lifting').anims.chain('looking').anims.chain('lowering'); This commit introduces a property nextAnimsQueue. It holds all additional nextAnim-Keys in the order the chain()-method was called. It is handed over to the nextAnim-Property in the stop()-method.
1 parent b00acb1 commit a391998

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 keys of the next Animations to be loaded into this Animation Controller when the current animation completes.
92+
*
93+
* @name Phaser.GameObjects.Components.Animation#nextAnimsQueue
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)