Skip to main content

Events

Nearly everything in Excalibur has a way to listen to events! This is useful when you want to know exactly when things happen in Excalibur and respond to them with game logic. Actors, Scenes, Engines, Actions, Animations, and various components have events you can hook into just look for the .events member!

info

Excalibur events are handled synchronously, which is great for debugging and reducing timing bugs.

Strongly Typed Events

Excalibur has types on all it's event listeners, you can check these types with intellisense in vscode or by following the typescript definition.

event auto complete

Excalibur also allows you to listen/send any event you want to as well, but you'll need to provide your own types for that.

typescript
interface MyEvents {
coolevent: MyCoolEvent;
forsure: ForSureEvent;
}
class MyActor extends Actor {
public events = new EventEmitter<ActorEvents & MyEvents>();
}
typescript
interface MyEvents {
coolevent: MyCoolEvent;
forsure: ForSureEvent;
}
class MyActor extends Actor {
public events = new EventEmitter<ActorEvents & MyEvents>();
}