Skip to content

Sprite in container not playing animation #6052

@adomas-sk

Description

@adomas-sk

Version

  • Phaser Version: any version newer than 3.52.0
  • Operating system: OSX
  • Browser: Firefox, Chrome

Description

When adding a sprite to a container and playing an animation, the animation is not playing (stuck on first frame). Found this bug in newest version (3.55.2), found a forum thread about this, but it seems no one issued a bug?
Forum thread with description: https://phaser.discourse.group/t/sprite-inside-container-doesnt-play-animations-in-phaser-3-53-and-newer/9765/4

Example Test Code

function preload() {
    this.load.spritesheet('character', 'src/assets/character.png', {
      frameWidth: 64,
      frameHeight: 64,
    });
  }

  function create() {
    this.anims.create({
      key: 'walk',
      frames: this.anims.generateFrameNumbers('character', {
        start: 2,
        end: 9,
      }),
      frameRate: 8,
      repeat: -1
    });
  const container = this.add.container(initData.x, initData.y);
  const sprite = new Phaser.GameObjects.Sprite(
      this,
      0,
      0,
      'character',
    );
    sprite.play('walk', true);
    container.add(sprite);
}

Additional Information

pinning Phaser to version 3.52.0 resolves the issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions