FIX: trackDirtyAnims now listen to more generic events

This commit is contained in:
kharhamel 2021-05-11 16:44:31 +02:00
parent 78d4985d10
commit 4ec5ad9e33

View File

@ -2,6 +2,7 @@ import {ResizableScene} from "../Login/ResizableScene";
import GameObject = Phaser.GameObjects.GameObject; import GameObject = Phaser.GameObjects.GameObject;
import Events = Phaser.Scenes.Events; import Events = Phaser.Scenes.Events;
import AnimationEvents = Phaser.Animations.Events; import AnimationEvents = Phaser.Animations.Events;
import StructEvents = Phaser.Structs.Events;
/** /**
* A scene that can track its dirty/pristine state. * A scene that can track its dirty/pristine state.
@ -23,12 +24,11 @@ export abstract class DirtyScene extends ResizableScene {
} }
this.isAlreadyTracking = true; this.isAlreadyTracking = true;
const trackAnimationFunction = this.trackAnimation.bind(this); const trackAnimationFunction = this.trackAnimation.bind(this);
this.events.on(Events.ADDED_TO_SCENE, (gameObject: GameObject) => { this.sys.updateList.on(StructEvents.PROCESS_QUEUE_ADD, (gameObject: GameObject) => {
this.objectListChanged = true; this.objectListChanged = true;
gameObject.on(AnimationEvents.ANIMATION_UPDATE, trackAnimationFunction); gameObject.on(AnimationEvents.ANIMATION_UPDATE, trackAnimationFunction);
}); });
this.sys.updateList.on(StructEvents.PROCESS_QUEUE_REMOVE, (gameObject: GameObject) => {
this.events.on(Events.REMOVED_FROM_SCENE, (gameObject: GameObject) => {
this.objectListChanged = true; this.objectListChanged = true;
gameObject.removeListener(AnimationEvents.ANIMATION_UPDATE, trackAnimationFunction); gameObject.removeListener(AnimationEvents.ANIMATION_UPDATE, trackAnimationFunction);
}); });