mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
[ts][phaser] Fix add/make not clearing and rebinding the WebGL pipeline.
This commit is contained in:
parent
b4a563b7ce
commit
0f8a707b48
@ -122,22 +122,42 @@ export class SpinePlugin extends Phaser.Plugins.ScenePlugin {
|
|||||||
};
|
};
|
||||||
pluginManager.registerFileType("spineAtlas", atlasFileCallback, scene);
|
pluginManager.registerFileType("spineAtlas", atlasFileCallback, scene);
|
||||||
|
|
||||||
let self = this;
|
|
||||||
let addSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, x: number, y: number, dataKey: string, atlasKey: string, boundsProvider: SpineGameObjectBoundsProvider) {
|
let addSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, x: number, y: number, dataKey: string, atlasKey: string, boundsProvider: SpineGameObjectBoundsProvider) {
|
||||||
let gameObject = new SpineGameObject(this.scene, self, x, y, dataKey, atlasKey, boundsProvider);
|
if (this.scene.sys.renderer instanceof Phaser.Renderer.WebGL.WebGLRenderer) {
|
||||||
|
this.scene.sys.renderer.pipelines.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
const spinePlugin = (this.scene.sys as any)[pluginKey] as SpinePlugin;
|
||||||
|
let gameObject = new SpineGameObject(this.scene, spinePlugin, x, y, dataKey, atlasKey, boundsProvider);
|
||||||
this.displayList.add(gameObject);
|
this.displayList.add(gameObject);
|
||||||
this.updateList.add(gameObject);
|
this.updateList.add(gameObject);
|
||||||
|
|
||||||
|
if (this.scene.sys.renderer instanceof Phaser.Renderer.WebGL.WebGLRenderer) {
|
||||||
|
this.scene.sys.renderer.pipelines.rebind();
|
||||||
|
}
|
||||||
|
|
||||||
return gameObject;
|
return gameObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: SpineGameObjectConfig, addToScene: boolean = false) {
|
let makeSpineGameObject = function (this: Phaser.GameObjects.GameObjectFactory, config: SpineGameObjectConfig, addToScene: boolean = false) {
|
||||||
|
if (this.scene.sys.renderer instanceof Phaser.Renderer.WebGL.WebGLRenderer) {
|
||||||
|
this.scene.sys.renderer.pipelines.clear();
|
||||||
|
}
|
||||||
|
|
||||||
let x = config.x ? config.x : 0;
|
let x = config.x ? config.x : 0;
|
||||||
let y = config.y ? config.y : 0;
|
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, config.dataKey, config.atlasKey, boundsProvider);
|
|
||||||
|
const spinePlugin = (this.scene.sys as any)[pluginKey] as SpinePlugin;
|
||||||
|
let gameObject = new SpineGameObject(this.scene, spinePlugin, x, y, config.dataKey, config.atlasKey, boundsProvider);
|
||||||
if (addToScene !== undefined) {
|
if (addToScene !== undefined) {
|
||||||
config.add = addToScene;
|
config.add = addToScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.scene.sys.renderer instanceof Phaser.Renderer.WebGL.WebGLRenderer) {
|
||||||
|
this.scene.sys.renderer.pipelines.rebind();
|
||||||
|
}
|
||||||
|
|
||||||
return Phaser.GameObjects.BuildGameObject(this.scene, gameObject, config);
|
return Phaser.GameObjects.BuildGameObject(this.scene, gameObject, config);
|
||||||
}
|
}
|
||||||
pluginManager.registerGameObject((window as any).SPINE_GAME_OBJECT_TYPE ? (window as any).SPINE_GAME_OBJECT_TYPE : SPINE_GAME_OBJECT_TYPE, addSpineGameObject, makeSpineGameObject);
|
pluginManager.registerGameObject((window as any).SPINE_GAME_OBJECT_TYPE ? (window as any).SPINE_GAME_OBJECT_TYPE : SPINE_GAME_OBJECT_TYPE, addSpineGameObject, makeSpineGameObject);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user