[phaser] Fix GameObjectCreator.spine parameter types.

This commit is contained in:
Mario Zechner 2023-04-21 14:05:32 +02:00
parent 8db318ab85
commit ba2eb2cf9c
2 changed files with 14 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}
}
}