Play new animation after last animation is complete

Hi! I am trying to play a new animation after the last one is completed.

This is my code:

if(Player.body.touching.down && activator == false) {
  activator= true;
  Player.anims.play('Animation1').on('animationcomplete', () =>
  {Player.anims.play('Animation2')
  })
}

The problem with my code is that the last animation plays over and over, and I only want it to play once.

Is there a solution?

Thanks a lot!

Hi @dawser95 ,
You need to change the method on to once. The method Sprite.once adds a one-time listener for a given event (docs)

Player.anims.play('Animation1').once('animationcomplete', () =>
  {Player.anims.play('Animation2')
  })
1 Like

Beautiful.

Thanks a lot!