Jelajahi Sumber

[phaser] Fix GameObjectCreator.spine parameter types.

Mario Zechner 2 tahun lalu
induk
melakukan
ba2eb2cf9c

+ 12 - 6
spine-ts/spine-phaser/src/SpinePlugin.ts

@@ -27,12 +27,20 @@
  * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * 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 { 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 { AtlasAttachmentLoader, Bone, GLTexture, SceneRenderer, Skeleton, SkeletonBinary, SkeletonData, SkeletonJson, TextureAtlas } from "@esotericsoftware/spine-webgl"
 import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject";
 import { SpineGameObject, SpineGameObjectBoundsProvider } from "./SpineGameObject";
 import { CanvasTexture, SkeletonRenderer } from "@esotericsoftware/spine-canvas";
 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 {
 export class SpinePlugin extends Phaser.Plugins.ScenePlugin {
 	game: Phaser.Game;
 	game: Phaser.Game;
 	isWebGL: boolean;
 	isWebGL: boolean;
@@ -105,13 +113,11 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin {
 			return gameObject;
 			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 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 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) {
 			if (addToScene !== undefined) {
 				config.add = addToScene;
 				config.add = addToScene;
 			}
 			}

+ 2 - 2
spine-ts/spine-phaser/src/index.ts

@@ -4,7 +4,7 @@ export * from "./SpineGameObject"
 export * from "./mixins"
 export * from "./mixins"
 export * from "@esotericsoftware/spine-core";
 export * from "@esotericsoftware/spine-core";
 export * from "@esotericsoftware/spine-webgl";
 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 };
 (window as any)["spine.SpinePlugin"] = SpinePlugin;
 (window as any)["spine.SpinePlugin"] = SpinePlugin;
 
 
@@ -25,7 +25,7 @@ declare global {
         }
         }
 
 
         export interface GameObjectCreator {
         export interface GameObjectCreator {
-            spine(config: any, addToScene: boolean): SpineGameObject;
+            spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
         }
         }
     }
     }
 }
 }