From 852fbb8f29ecadefa132fb76c071d406c9972c52 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Wed, 29 Nov 2023 22:26:01 -0600 Subject: [PATCH] fix: Trigger event signature type was incorrect --- CHANGELOG.md | 2 ++ src/engine/Trigger.ts | 14 +++++++------- src/spec/TriggerSpec.ts | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97fedfcac..6c791fb62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed typo in trigger event signature `entertrigger` should have been `enter` +- Fixed typo in trigger event signature `exittrigger` should have been `exit` - Fixed typo in animation event signature `ended` should have been `end` - Fixed issue where some excalibur `clear()`` implementations modified the collection they were iterating over - Fixed async issue where sound could not be stopped if stop()/start() were called in rapid succession diff --git a/src/engine/Trigger.ts b/src/engine/Trigger.ts index f90de9a33..d944f6f68 100644 --- a/src/engine/Trigger.ts +++ b/src/engine/Trigger.ts @@ -7,13 +7,13 @@ import { Actor, ActorEvents } from './Actor'; import { EventEmitter } from './EventEmitter'; export type TriggerEvents = ActorEvents & { - exittrigger: ExitTriggerEvent, - entertrigger: EnterTriggerEvent + exit: ExitTriggerEvent, + enter: EnterTriggerEvent } export const TriggerEvents = { - ExitTrigger: 'exittrigger', - EnterTrigger: 'entertrigger' + ExitTrigger: 'exit', + EnterTrigger: 'enter' }; /** @@ -56,7 +56,7 @@ const triggerDefaults: Partial = { * are invisible, and can only be seen when [[Trigger.visible]] is set to `true`. */ export class Trigger extends Actor { - public events = new EventEmitter(); + public events = new EventEmitter(); private _target: Entity; /** * Action to fire when triggered by collision @@ -97,7 +97,7 @@ export class Trigger extends Actor { this.events.on('collisionstart', (evt: CollisionStartEvent) => { if (this.filter(evt.other)) { - this.emit('enter', new EnterTriggerEvent(this, evt.other)); + this.events.emit('enter', new EnterTriggerEvent(this, evt.other)); this._dispatchAction(); // remove trigger if its done, -1 repeat forever if (this.repeat === 0) { @@ -108,7 +108,7 @@ export class Trigger extends Actor { this.events.on('collisionend', (evt: CollisionEndEvent) => { if (this.filter(evt.other)) { - this.emit('exit', new ExitTriggerEvent(this, evt.other)); + this.events.emit('exit', new ExitTriggerEvent(this, evt.other)); } }); } diff --git a/src/spec/TriggerSpec.ts b/src/spec/TriggerSpec.ts index 4ef939315..f96ff7d89 100644 --- a/src/spec/TriggerSpec.ts +++ b/src/spec/TriggerSpec.ts @@ -174,8 +174,8 @@ describe('A Trigger', () => { const exitSpy = jasmine.createSpy('exit'); const collisionEnd = jasmine.createSpy('collisionend'); - trigger.on('exit', exitSpy); - trigger.on('collisionend', collisionEnd); + trigger.events.on('exit', exitSpy); + trigger.events.on('collisionend', collisionEnd); // Act actor.vel = ex.vec(0, 10);