phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Custom objects not updating in Container

Open TadejZupancic opened this issue 8 years ago • 2 comments

CustomSprite - a custom object extending Sprite

var s = new CustomSprite(...);
this.add.container(0, 0, [s]);

This code adds this CustomSprite to the Container's displayList, but does not add it to the updateList, so animations do not work. It's a bit confusing, since it looks like it works, because it displays fine, but it doesn't update.

If you call this.add.existing(s) before adding it to the Container, it is also added to the Scene's updateList and animations work fine.

I don't know if this is a bug or should you always add the object to the Scene first. In case it is a bug, it can be easily fixed by adding the object to the updateList in the Container's addHandler:

if (gameObject.preUpdate)
{
    this._updateList.add(gameObject);
}

I can make a pull request if this is considered a bug.

TadejZupancic avatar Jun 20 '18 10:06 TadejZupancic

Don't PR this as I'm changing the way the update list works very soon (if not in 3.11 then in 3.12)

photonstorm avatar Jun 20 '18 10:06 photonstorm

Great, I'll wait.

TadejZupancic avatar Jun 20 '18 10:06 TadejZupancic