The Spine Plugin add and make functions didn't clear and rebind the WebGL pipeline. This could cause two different visual issues: The first is that a Phaser Game Object (such as a Sprite) could be seen to change its texture to display the Spine atlas texture instead for a single frame, and then on the next pass revert back to normal again. The second issue is that if the Spine skeleton wasn't added to the display list, but just created (via addToScene: false) then the Sprite would take on the texture frame entirely from that point on. Fix #6362

This commit is contained in:
Richard Davey 2023-02-06 16:44:32 +00:00
parent b2f9c522ff
commit 1fa400b431

View file

@ -319,14 +319,26 @@ var SpinePlugin = new Class({
}; };
} }
var isWebGL = this.isWebGL;
var add = function (x, y, key, animationName, loop) var add = function (x, y, key, animationName, loop)
{ {
if (isWebGL)
{
this.scene.sys.renderer.pipelines.clear();
}
var spinePlugin = this.scene.sys[pluginKey]; var spinePlugin = this.scene.sys[pluginKey];
var spineGO = new SpineGameObject(this.scene, spinePlugin, x, y, key, animationName, loop); var spineGO = new SpineGameObject(this.scene, spinePlugin, x, y, key, animationName, loop);
this.displayList.add(spineGO); this.displayList.add(spineGO);
this.updateList.add(spineGO); this.updateList.add(spineGO);
if (isWebGL)
{
this.scene.sys.renderer.pipelines.rebind();
}
return spineGO; return spineGO;
}; };
@ -334,6 +346,11 @@ var SpinePlugin = new Class({
{ {
if (config === undefined) { config = {}; } if (config === undefined) { config = {}; }
if (isWebGL)
{
this.scene.sys.renderer.pipelines.clear();
}
var key = GetValue(config, 'key', null); var key = GetValue(config, 'key', null);
var animationName = GetValue(config, 'animationName', null); var animationName = GetValue(config, 'animationName', null);
var loop = GetValue(config, 'loop', false); var loop = GetValue(config, 'loop', false);
@ -364,6 +381,11 @@ var SpinePlugin = new Class({
spineGO.setAttachment(slotName, attachmentName); spineGO.setAttachment(slotName, attachmentName);
} }
if (isWebGL)
{
this.scene.sys.renderer.pipelines.rebind();
}
return spineGO.refresh(); return spineGO.refresh();
}; };
@ -654,7 +676,7 @@ var SpinePlugin = new Class({
* @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the Spine json file. Used in replacement of the Loaders default XHR Settings. * @param {Phaser.Types.Loader.XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the Spine json file. Used in replacement of the Loaders default XHR Settings.
* @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the Spine atlas file. Used in replacement of the Loaders default XHR Settings. * @param {Phaser.Types.Loader.XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the Spine atlas file. Used in replacement of the Loaders default XHR Settings.
* @param {object} [settings] - An external Settings configuration object { prefix: '' } * @param {object} [settings] - An external Settings configuration object { prefix: '' }
* *
* @return {Phaser.Loader.LoaderPlugin} The Loader instance. * @return {Phaser.Loader.LoaderPlugin} The Loader instance.
*/ */
spineFileCallback: function (key, jsonURL, atlasURL, preMultipliedAlpha, jsonXhrSettings, atlasXhrSettings, settings) spineFileCallback: function (key, jsonURL, atlasURL, preMultipliedAlpha, jsonXhrSettings, atlasXhrSettings, settings)