workadventure/front/src/Phaser/Entity/CustomizedCharacter.ts
David Négrier e3ee66527a Fixing bug slowing down the CustomizeScene a lot
By forcing the containers to be updated only in the "update" method, we seem to be solving some bugs regarding the way sprites are handled.
There is still an issue though. Some times, for some reasons, the update list seems to be growing a lot.
The more we click the left/right arrow to choose a character, the slower it gets (but with this commit, it does not lock anymore)
2021-06-14 16:32:09 +02:00

21 lines
608 B
TypeScript

import Container = Phaser.GameObjects.Container;
import type {Scene} from "phaser";
import Sprite = Phaser.GameObjects.Sprite;
/**
* A sprite of a customized character (used in the Customize Scene only)
*/
export class CustomizedCharacter extends Container {
public constructor(scene: Scene, x: number, y: number, layers: string[]) {
super(scene, x, y);
this.updateSprites(layers);
}
public updateSprites(layers: string[]): void {
this.removeAll(true);
for (const layer of layers) {
this.add(new Sprite(this.scene, 0, 0, layer));
}
}
}