Merge pull request #5159 from tgroborsch/feature/multi-anims-chain

Allow chaining of multible animations
This commit is contained in:
Richard Davey 2020-07-13 12:19:03 +01:00 committed by GitHub
commit 8951211c74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;
}
this.nextAnim = 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);
}