From ba2eb2cf9c547283219ee32c4ccc4a94453e0b30 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 21 Apr 2023 14:05:32 +0200 Subject: [PATCH] [phaser] Fix GameObjectCreator.spine parameter types. --- spine-ts/spine-phaser/src/SpinePlugin.ts | 18 ++++++++++++------ spine-ts/spine-phaser/src/index.ts | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spine-ts/spine-phaser/src/SpinePlugin.ts b/spine-ts/spine-phaser/src/SpinePlugin.ts index 26f64bbfc..43fad4add 100644 --- a/spine-ts/spine-phaser/src/SpinePlugin.ts +++ b/spine-ts/spine-phaser/src/SpinePlugin.ts @@ -27,12 +27,20 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -import Phaser from "phaser"; +import phaser from "phaser"; import { SPINE_ATLAS_CACHE_KEY, SPINE_CONTAINER_TYPE, SPINE_GAME_OBJECT_TYPE, SPINE_ATLAS_TEXTURE_CACHE_KEY, SPINE_SKELETON_DATA_FILE_TYPE, SPINE_ATLAS_FILE_TYPE, SPINE_SKELETON_FILE_CACHE_KEY as SPINE_SKELETON_DATA_CACHE_KEY } from "./keys"; import { AtlasAttachmentLoader, Bone, GLTexture, SceneRenderer, Skeleton, SkeletonBinary, SkeletonData, SkeletonJson, TextureAtlas } from "@esotericsoftware/spine-webgl" import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject"; import { CanvasTexture, SkeletonRenderer } from "@esotericsoftware/spine-canvas"; +export interface SpineGameObjectConfig extends Phaser.Types.GameObjects.GameObjectConfig { + x?: number, + y?: number, + dataKey: string, + atlasKey: string + boundsProvider?: SpineGameObjectBoundsProvider +} + export class SpinePlugin extends Phaser.Plugins.ScenePlugin { game: Phaser.Game; isWebGL: boolean; @@ -105,13 +113,11 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin { return gameObject; }; - let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: any, addToScene: boolean) { + let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: SpineGameObjectConfig, addToScene: boolean) { let x = config.x ? config.x : 0; - let y = config.y ? config.y : 0; - let dataKey = config.dataKey ? config.dataKey : null; - let atlasKey = config.atlasKey ? config.atlasKey : null; + let y = config.y ? config.y : 0; let boundsProvider = config.boundsProvider ? config.boundsProvider : undefined; - let gameObject = new SpineGameObject(this.scene, self, x, y, dataKey, atlasKey, boundsProvider); + let gameObject = new SpineGameObject(this.scene, self, x, y, config.dataKey, config.atlasKey, boundsProvider); if (addToScene !== undefined) { config.add = addToScene; } diff --git a/spine-ts/spine-phaser/src/index.ts b/spine-ts/spine-phaser/src/index.ts index fa6357b7e..e7a2f8713 100644 --- a/spine-ts/spine-phaser/src/index.ts +++ b/spine-ts/spine-phaser/src/index.ts @@ -4,7 +4,7 @@ export * from "./SpineGameObject" export * from "./mixins" export * from "@esotericsoftware/spine-core"; export * from "@esotericsoftware/spine-webgl"; -import { SpinePlugin } from "./SpinePlugin"; +import { SpineGameObjectConfig, SpinePlugin } from "./SpinePlugin"; (window as any).spine = { SpinePlugin: SpinePlugin }; (window as any)["spine.SpinePlugin"] = SpinePlugin; @@ -25,7 +25,7 @@ declare global { } export interface GameObjectCreator { - spine(config: any, addToScene: boolean): SpineGameObject; + spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject; } } }