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.
This commit is contained in:
timo 2020-05-22 14:03:42 +02:00
parent b00acb1838
commit a39199849e

View file

@ -87,6 +87,15 @@ var Animation = new Class({
*/
this.nextAnim = null;
/**
* A queue of keys of the next Animations to be loaded into this Animation Controller when the current animation completes.
*
* @name Phaser.GameObjects.Components.Animation#nextAnimsQueue
* @type {Array}
* @default []
*/
this.nextAnimsQueue = [];
/**
* Time scale factor.
*
@ -321,7 +330,11 @@ var Animation = new Class({
key = key.key;
}
if(this.nextAnim === null){
this.nextAnim = key;
} else {
this.nextAnimsQueue.push(key);
}
return this.parent;
},
@ -850,7 +863,7 @@ var Animation = new Class({
{
var key = this.nextAnim;
this.nextAnim = null;
this.nextAnim = this.nextAnimsQueue.length > 0 ? this.nextAnimsQueue.shift() : null;
this.play(key);
}