/****************************************************************************** * Spine Runtimes License Agreement * Last updated April 5, 2025. Replaces all prior versions. * * Copyright (c) 2013-2025, Esoteric Software LLC * * Integration of the Spine Runtimes into software or otherwise creating * derivative works of the Spine Runtimes is permitted under the terms and * conditions of Section 2 of the Spine Editor License Agreement: * http://esotericsoftware.com/spine-editor-license * * Otherwise, it is permitted to integrate the Spine Runtimes into software * or otherwise create derivative works of the Spine Runtimes (collectively, * "Products"), provided that each user of the Products must obtain their own * Spine Editor license and redistribution of the Products in any form must * include this license and copyright notice. * * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ import { AnimationState, AnimationStateData, type Bone, type Skeleton, type SkeletonCoordinateConverter, SkeletonPhysicsMovement } from "@esotericsoftware/spine-core"; import * as Phaser from "phaser"; import { type SpineGameObjectBoundsProvider } from "./SpineGameObjectBounds.js"; import type { SpinePlugin } from "./SpinePlugin.js"; export type { SpineGameObjectBoundsProvider } from "./SpineGameObjectBounds.js"; export { AABBRectangleBoundsProvider, SetupPoseBoundsProvider, SkinsAndAnimationBoundsProvider } from "./SpineGameObjectBounds.js"; declare class BaseSpineGameObject extends Phaser.GameObjects.GameObject { constructor(scene: Phaser.Scene, type: string); } /** Options used to construct a {@link SpineGameObject}. */ export interface SpineGameObjectOptions { /** Initial x-position in Phaser coordinates. */ x?: number; /** Initial y-position in Phaser coordinates. */ y?: number; /** Phaser cache key for the loaded Spine skeleton data. */ dataKey: string; /** Phaser cache key for the loaded Spine atlas. */ atlasKey: string; /** Bounds provider used to calculate the Phaser GameObject size and display origin. */ boundsProvider?: SpineGameObjectBoundsProvider; } /** Options accepted by the `this.add.spine(...)` factory after position and cache keys. */ export type SpineGameObjectFactoryOptions = Omit; declare const SpineGameObject_base: typeof BaseSpineGameObject & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type & import("./mixins.js").Type; /** * A SpineGameObject is a Phaser {@link GameObject} that can be added to a Phaser Scene and render a Spine skeleton. * * The Spine GameObject is a thin wrapper around a Spine {@link Skeleton}, {@link AnimationState} and {@link AnimationStateData}. It is responsible for: * - updating the animation state * - applying the animation state to the skeleton's bones, slots, attachments, and draw order. * - updating the skeleton's bone world transforms * - rendering the skeleton * * See the {@link SpinePlugin} class for more information on how to create a `SpineGameObject`. * * The skeleton, animation state, and animation state data can be accessed via the repsective fields. They can be manually updated via {@link updatePose}. * * To modify the bone hierarchy before the world transforms are computed, a callback can be set via the {@link beforeUpdateWorldTransforms} field. * * To modify the bone hierarchy after the world transforms are computed, a callback can be set via the {@link afterUpdateWorldTransforms} field. * * The class also features methods to convert between the skeleton coordinate system and the Phaser coordinate system. * * See {@link skeletonToGame}, {@link gameToSkeleton}, and {@link gameToBone}. */ export declare class SpineGameObject extends SpineGameObject_base implements SkeletonCoordinateConverter { readonly plugin: SpinePlugin; blendMode: number; skeleton: Skeleton; animationStateData: AnimationStateData; animationState: AnimationState; beforeUpdateWorldTransforms: (object: SpineGameObject) => void; afterUpdateWorldTransforms: (object: SpineGameObject) => void; private offsetX; private offsetY; /** Tracks this GameObject's transform movement and applies it to skeleton physics constraints when enabled. */ readonly skeletonPhysics: SkeletonPhysicsMovement; constructor(scene: Phaser.Scene, plugin: SpinePlugin, options: SpineGameObjectOptions); /** @deprecated Pass a {@link SpineGameObjectOptions} object as the third argument instead. */ constructor(scene: Phaser.Scene, plugin: SpinePlugin, x: number, y: number, dataKey: string, atlasKey: string, boundsProvider?: SpineGameObjectBoundsProvider); /** Bounds provider used to calculate this GameObject's size and display origin. */ boundsProvider: SpineGameObjectBoundsProvider; updateSize(): void; /** Horizontal skeleton render offset from the Phaser GameObject origin. */ get renderOffsetX(): number; /** Vertical skeleton render offset from the Phaser GameObject origin. */ get renderOffsetY(): number; /** Converts `point` in-place from skeleton coordinates to Phaser game coordinates. */ skeletonToGame(point: { x: number; y: number; }): void; /** Converts `point` in-place from Phaser game coordinates to skeleton coordinates. */ gameToSkeleton(point: { x: number; y: number; }): void; /** Converts `point` in-place from Phaser game coordinates to a bone's local coordinates. */ gameToBone(point: { x: number; y: number; }, bone: Bone): void; /** @deprecated Use {@link skeletonToGame} instead. */ skeletonToPhaserWorldCoordinates(point: { x: number; y: number; }): void; /** @deprecated Use {@link gameToSkeleton} instead. */ phaserWorldCoordinatesToSkeleton(point: { x: number; y: number; }): void; /** @deprecated Use {@link gameToBone} instead. */ phaserWorldCoordinatesToBone(point: { x: number; y: number; }, bone: Bone): void; /** * Updates the {@link AnimationState}, applies it to the {@link Skeleton}, then updates the world transforms of all bones. * @param delta The time delta in milliseconds */ updatePose(delta: number): void; preUpdate(_time: number, delta: number): void; preDestroy(): void; willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; }