/****************************************************************************** * 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, type Slot } from "@esotericsoftware/spine-core"; import * as Phaser from "phaser"; import type { SpineGameObjectRendererType } from "./renderers/SpineGameObjectRenderer.js"; import { type SpineGameObjectBoundsProvider } from "./SpineGameObjectBounds.js"; import type { SpinePlugin } from "./SpinePlugin.js"; export type { SpineGameObjectRendererType } from "./renderers/SpineGameObjectRenderer.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 for attaching a Phaser GameObject to a Spine slot. */ export interface SpineSlotObjectOptions { /** If true, the attached GameObject is hidden when the slot has no attachment. */ followAttachmentTimeline?: boolean; /** Whether to render the GameObject before or after the slot attachment. */ placement?: "before" | "after"; /** If true, active Spine clipping attachments also clip the attached GameObject. */ clipping?: boolean; /** If true, keep the GameObject's current x/y as a local offset from the slot. Defaults to false. */ preservePosition?: boolean; } /** Runtime state for a Phaser GameObject attached to a Spine slot. */ export interface SpineSlotObjectEntry extends Required { /** The Phaser GameObject attached to the slot. */ gameObject: Phaser.GameObjects.GameObject; } /** 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; /** Renderer backend. Defaults to `"phaser"` in WebGL games and `"spine-canvas"` in Canvas games. */ renderer?: SpineGameObjectRendererType; } /** 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 & import("./mixins.js").Type; /** Phaser GameObject that displays and updates a Spine skeleton. */ export declare class SpineGameObject extends SpineGameObject_base implements SkeletonCoordinateConverter { readonly plugin: SpinePlugin; blendMode: number; skeleton: Skeleton; animationStateData: AnimationStateData; animationState: AnimationState; /** Called after animation state is applied and before skeleton world transforms are updated. */ beforeUpdateWorldTransforms: (object: SpineGameObject) => void; /** Called after skeleton world transforms are updated. */ afterUpdateWorldTransforms: (object: SpineGameObject) => void; private readonly slotObjects; private offsetX; private offsetY; /** Tracks this GameObject's transform movement and applies it to skeleton physics constraints when enabled. */ readonly skeletonPhysics: SkeletonPhysicsMovement; /** Renderer backend selected for this GameObject. */ readonly rendererType: SpineGameObjectRendererType; private rendererBackend; 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); /** * Sets a uniform tint color for the skeleton. * * Spine skeletons do not support Phaser's four-corner gradient tint. Only the * first color is used; the other arguments are accepted for Phaser API compatibility. * @param topLeft Tint color applied to the whole skeleton. * @param _topRight Ignored. * @param _bottomLeft Ignored. * @param _bottomRight Ignored. */ setTint(topLeft?: number, _topRight?: number, _bottomLeft?: number, _bottomRight?: number): this; clearTint(): this; /** Bounds provider used to calculate this GameObject's size and display origin. */ boundsProvider: SpineGameObjectBoundsProvider; /** Recalculates this GameObject's size and display origin from its bounds provider. */ 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. * @param point The point to convert. */ skeletonToGame(point: { x: number; y: number; }): void; /** * Converts `point` in-place from Phaser game coordinates to skeleton coordinates. * @param point The point to convert. */ gameToSkeleton(point: { x: number; y: number; }): void; /** * Converts `point` in-place from Phaser game coordinates to a bone's local coordinates. * @param point The point to convert. * @param bone The bone whose local coordinates should receive the converted point. */ 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; /** * Attaches a Phaser GameObject to a Spine slot. * While attached, the SpineGameObject controls the GameObject's scroll factors so it remains anchored to the slot. * Removing it does not restore its previous scroll factors. * @param slotRef Slot index, slot name, or Slot instance. * @param gameObject Phaser GameObject to render at the slot. * @param options Slot-object rendering options. */ addSlotObject(slotRef: number | string | Slot, gameObject: Phaser.GameObjects.GameObject, options?: SpineSlotObjectOptions): void; /** * Returns the Phaser GameObject attached to a Spine slot, if any. * @param slotRef Slot index, slot name, or Slot instance. * @returns The attached Phaser GameObject, or `undefined`. */ getSlotObject(slotRef: number | string | Slot): Phaser.GameObjects.GameObject | undefined; /** * Removes the Phaser GameObject attached to a Spine slot. * @param slotRef Slot index, slot name, or Slot instance. * @param gameObject Optional GameObject guard. If supplied, removal only occurs when it is the attached object. */ removeSlotObject(slotRef: number | string | Slot, gameObject?: Phaser.GameObjects.GameObject): void; /** Removes all Phaser GameObjects attached to Spine slots. */ removeSlotObjects(): void; /** * Updates animation state, applies it to the skeleton, and updates skeleton world transforms. * @param delta Time delta in milliseconds. */ updatePose(delta: number): void; preUpdate(_time: number, delta: number): void; willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; renderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, src: SpineGameObject, drawingContext: Phaser.Renderer.WebGL.DrawingContext, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix, renderStep?: number, displayList?: Phaser.GameObjects.GameObject[], displayListIndex?: number): void; renderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, src: SpineGameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; preDestroy(): void; /** * Returns the internal slot object entry for a slot. * @param slot The slot to query. * @returns The slot object entry, or `undefined`. */ getSlotObjectEntry(slot: Slot): SpineSlotObjectEntry | undefined; /** * Resolves a slot index, name, or Slot instance to a Slot. * @param slotRef Slot index, slot name, or Slot instance. * @returns The resolved Slot. */ getSlot(slotRef: number | string | Slot): Slot; private requireSlotObjectSupport; private removeGameObjectFromOtherSlots; }