Turn off audio on exit

If an exit zone is overlapping an audio zone, when exiting, the audio is stopped.
We do this by actually triggering the fact that a user should "leave" all active zones when exiting.
This commit is contained in:
David Négrier 2021-09-15 15:28:55 +02:00
parent 8a6419a3b7
commit 801ec3bf4c
3 changed files with 36 additions and 5 deletions

View file

@ -286,4 +286,15 @@ export class GameMap {
this.triggerAll();
}
/**
* Trigger all the callbacks (used when exiting a map)
*/
public triggerExitCallbacks(): void {
const emptyProps = new Map<string, string | boolean | number>();
for (const [oldPropName, oldPropValue] of this.lastProperties.entries()) {
// We found a property that disappeared
this.trigger(oldPropName, oldPropValue, undefined, emptyProps);
}
}
}