Common Game Events
The engine provides many predefined events that are useful in most games. Understanding these events and when to use them helps to build the game faster.
System Events
System events are always emitted regardless of how you initialize the engine. These events handle core engine functionality.
Update Event
The UpdateEvent.UPDATE event is dispatched every frame and provides the delta time since the last frame. Use this event for frame-based animations, continuous calculations, or any logic that needs to run every frame.
System.appendListener(UpdateEvent.UPDATE, (event:Event<number>) => {
const deltaTime = event.data;
// Update animations or time-based logic
this.animationController.update(deltaTime);
this.particleSystem.update(deltaTime);
});
Resize Event
The resize event is dispatched when the game viewport changes size. Use this event to apply adjustments for the responsive layout.
System.appendListener(ResizeEvent.RESIZE, (event:Event<DeviceManager>) => {
const { width, height } = event.data.deviceSize;
// Adjust background size for new dimensions
this.background.width = width;
this.background.height = height;
});
Template Events
Template events are available when you use the PlayerController option to initialize the engine. They cover template lifecycle, player model changes, round flow, feature toggles, jurisdiction requirements, and autoplay automation.
Template Flow Events
Template flow events manage the game flow and are essential for game components initialization:
TemplateEvent.CREATE_SPLASH_SCREEN– Dispatched before the splash scene is created.TemplateEvent.SHOW_SPLASH_SCREEN– Dispatched when the splash scene becomes visible.TemplateEvent.HIDE_SPLASH_SCREEN– Dispatched right before the splash scene is removed; useful for cleanup.TemplateEvent.CREATE_MAIN_SCENE– Dispatched when the main scene is created.TemplateEvent.SHOW_INTRO– Dispatched when the intro sequence is about to run.TemplateEvent.SHOW_MAIN_SCREEN– Dispatched when the main scene becomes visible.
As a developer, you might often use TemplateEvent.CREATE_MAIN_SCENE event. This event is dispatched when the main scene is created and all components are available. You can use this event to finish initialization of your custom game components.
export class BackgroundContainer extends Container {
// Animation, added to the BackgroundContainer in the editor
protected readonly _animation:SpineAnimation;
public constructor() {
super();
System.appendListener(TemplateEvent.CREATE_MAIN_SCENE, this.createMainSceneHandler);
// Returns undefined, because the animation is not created yet
console.log(this._animation);
}
protected createMainSceneHandler = ():void => {
// Returns an actual animation, because it's available now
console.log(this._animation);
};
}
Round Events
Round events notify about the round lifecycle. You can use them to change components visibility and/or state when the round starts, stops, or changes phases.
RoundEvent.START– Dispatched when the round starts.RoundEvent.RESTORE– Dispatched when the round is restored, typically after a game interruption or reload.RoundEvent.PROCESS_PHASE– Dispatched when a new round phase is being processed.RoundEvent.STOP– Dispatched when the round stops.RoundEvent.INTERRUPT– Dispatched when the round is interrupted.
export class ProgressContainer extends Container {
// Animation, added to the ProgressContainer in the editor
protected readonly _progressBar:SpineAnimation;
public constructor() {
super();
System.appendListener(RoundEvent.START, this.roundStartHandler);
}
protected roundStartHandler = (event:TimelineEvent):void => {
event.timeline = (
// Wait for the animation to finish, before actually starting the round
Actions.waitAnimation(this._progressBar, 'level_0')
);
};
}
Model Events
Model events notify about changes in the player's state:
ModelEvent.REQUEST_BALANCE– Requests the current balance to be changed.ModelEvent.REQUEST_BET– Requests the currently selected bet to be changed.ModelEvent.REQUEST_MAX_BET– Requests the maximum allowed bet to be set.ModelEvent.CHANGE_STATE– Dispatched whn session state transitions, such as enteringPLAYINGorINACTIVE.ModelEvent.CHANGE_BALANCE– Dispatched after the balance changes.ModelEvent.COLLECT_WIN– Dispatched when win counter is accumulating a new win.ModelEvent.CHANGE_ROUND_WIN– Dispatched when the total round win changed.ModelEvent.CHANGE_SPIN_WIN– Dispatched when the current spin win changed.ModelEvent.CHANGE_BET– Dispatched after the currently selected bet changed.
Feature Events
Feature events notify about feature state changes. These events should be dispatched by the game itself to help the Spinorium engine manage the internal state properly:
FeatureEvent.FREE_SPINS_START– Dispatched when a Free Spins feature starts.FeatureEvent.FREE_SPINS_STOP– Dispatched when a Free Spins feature stops.FeatureEvent.BONUS_GAME_START– Dispatched when a Bonus Game feature starts.FeatureEvent.BONUS_GAME_STOP– Dispatched when a Bonus Game feature stops.
Autoplay Events
Autoplay events manage automatic spinning functionality:
AutoplayEvent.REQUEST_START– Requests autoplay start with the provided number of rounds.AutoplayEvent.REQUEST_SETTINGS– Requests a settings update; ignored while autoplay is running.AutoplayEvent.REQUEST_STOP– Requests autoplay to stop regardless of remaining rounds.AutoplayEvent.START– Dispatched when autoplay has successfully started.AutoplayEvent.SETTINGS– Dispatched when autoplay settings have been successfully changed.AutoplayEvent.UPDATE– Dispatched when the autoplay round counter is updated.AutoplayEvent.COMPLETE– Dispatched when autoplay completes all requested rounds.AutoplayEvent.STOP– Dispatched when autoplay is manually stopped before completion.
Jurisdiction Events
Jurisdiction events handle regulatory and compliance requirements:
JurisdictionEvent.REALITY_CHECK– Dispatched when a jurisdiction-mandated reality check is triggered.JurisdictionEvent.BET_COOLDOWN_START– Dispatched when a bet cooldown period starts, preventing the player from placing bets temporarily.JurisdictionEvent.BET_COOLDOWN_END– Dispatched when a bet cooldown period ends, allowing the player to place bets again.