Play Animations for all Sprites in a Container


Hi there,

I have a container with multiple sprites and the username of the player. I want all the sprites in the container to play the same animation.

These sprites have the same structure, so the frames are the same for all sprites. It seems like you have to create an animation for each sprite, which can get confusing after a while.

I also tried to put everything into a group, but when using tweens it shifts.

Can someone help me?


If it’s always the same animation, you create it once. For example :

let animConfig = {
      key: 'fire_mg',
      frames: this.anims.generateFrameNumbers('bullet', {start: 0, end: 1}),
      frameRate: 70

Later, your sprite plays it :'fire_mg');


I’ve already tried that, but the animation then uses the sprite defined in “generateFrameNumbers”.

I want to use the animation on other sprites too.