From 4e1fe97fb33703d5100ea20f6cff7a99c3a58b93 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Sun, 20 Jun 2021 18:51:22 -0400 Subject: [PATCH] [ts] Player, added config.update and config.draw. --- spine-ts/player/src/Player.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spine-ts/player/src/Player.ts b/spine-ts/player/src/Player.ts index efc26186c..4ca95ff1e 100644 --- a/spine-ts/player/src/Player.ts +++ b/spine-ts/player/src/Player.ts @@ -140,6 +140,12 @@ module spine { /* Optional: Callback when the skeleton could not be loaded or rendered. Default: none */ error: (player: SpinePlayer, msg: string) => void + /* Optional: Callback just after the skeleton is posed each frame. Default: none */ + update: (player: SpinePlayer) => void + + /* Optional: Callback just after the skeleton is drawn each frame. Default: none */ + draw: (player: SpinePlayer) => void + /* Optional: The downloader used by the player's asset manager. Passing the same downloader to multiple players using the same assets ensures the assets are only downloaded once. Default: new instance */ downloader: spine.Downloader @@ -733,6 +739,7 @@ module spine { this.animationState.update(delta); this.animationState.apply(skeleton); skeleton.updateWorldTransform(); + if (config.update) config.update(this); } // Determine the viewport. @@ -795,6 +802,7 @@ module spine { ) { renderer.drawSkeletonDebug(skeleton, config.premultipliedAlpha); } + if (config.draw) config.draw(this); // Draw the control bones. let controlBones = config.controlBones;