Skip to main content

Client Scene Hooks

Scene hooks allow you to customize the behavior of scenes (maps) on the client side. These hooks are defined in the sceneMap property of your client module.

Usage

Composable SceneMap Component

Use sceneMap.component to wrap the default scene renderer and add scene-level CanvasEngine components without replacing the map component returned by provideLoadMap().
Children passed to SceneMap are rendered in the map scene after the map renderer and before component animations, projectiles, and weather. If the custom element must be sorted with players and events, put it inside EventLayerComponent in the map component instead.

Available Hooks

onBeforeLoading

Description: Called before the scene starts loading Parameters:
  • scene: RpgSceneMap - The scene instance
Example:

onAfterLoading

Description: Called after the scene has finished loading (images loaded, drawing completed, viewport assigned) Parameters:
  • scene: RpgSceneMap - The scene instance
Example:

onMapLoading

Description: Called while the map and resources are being loaded Parameters:
  • scene: RpgSceneMap - The scene instance
  • loader: PIXI.Loader - The PIXI loader instance
Example:

onAddSprite

Description: Called when a sprite is added to the scene Parameters:
  • scene: RpgSceneMap - The scene instance
  • sprite: RpgSprite - The sprite being added
Example:

onRemoveSprite

Description: Called when a sprite is removed from the scene Parameters:
  • scene: RpgSceneMap - The scene instance
  • sprite: RpgSprite - The sprite being removed
Example:

onChanges

Description: Called when server data changes on the map Parameters:
  • scene: RpgSceneMap - The scene instance
  • obj: { data: any, partial: any } - Change data
Example:

onDraw

Description: Called when the scene is being drawn (each frame) Parameters:
  • scene: RpgSceneMap - The scene instance
  • t: number - Current timestamp
Example:

Complete Example