Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite in container not playing animation #6052

Closed
adomas-sk opened this issue Mar 25, 2022 · 5 comments
Closed

Sprite in container not playing animation #6052

adomas-sk opened this issue Mar 25, 2022 · 5 comments

Comments

@adomas-sk
Copy link

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

@samme
Copy link
Contributor

samme commented Mar 28, 2022

#5817

@sushovande
Copy link

I am facing the same issue. Here is another repro: https://jsfiddle.net/sushovande/muafr6jc/

Note: the workaround is the manually add the same sprite to the scene again, that forces it to be updated.

photonstorm added a commit that referenced this issue Jun 7, 2022
… in the same frame were not correctly removed from the UpdateList. Fix #5803 #5817 #5818 #6052

* `ProcessQueue.isActive` is a new method that tests if the given object is in the active list, or not.
* `ProcessQueue.isPending` is a new method that tests if the given object is in the pending insertion list, or not.
* `ProcessQueue.isDestroying` is a new method that tests if the given object is pending destruction, or not.
* `ProcessQueue.add` will no longer place the item into the pending list if it's already active or pending.
* `ProcessQueue.remove` will check if the item is in the pending list, and simply remove it, rather than destroying it.
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

@sushovande
Copy link

it still repros on 3.60.0-beta-9 https://jsfiddle.net/sushovande/wjec9qh8/2/

@photonstorm
Copy link
Collaborator

it still repros on 3.60.0-beta-9 https://jsfiddle.net/sushovande/wjec9qh8/2/

This is fixed. Test case here: http://labs.phaser.io/view.html?src=src/bugs/6052%20anim%20in%20container.js&v=dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants