Merge pull request #4893 from FostUK/spine-manifest-loading

Support for loading spine files via manifest
This commit is contained in:
Richard Davey 2020-04-27 12:28:23 +01:00 committed by GitHub
commit 0e8d292809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -30,7 +30,7 @@ var TextFile = require('../../../src/loader/filetypes/TextFile.js');
* A Spine File suitable for loading by the Loader. * A Spine File suitable for loading by the Loader.
* *
* These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly. * These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly.
* *
* For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine. * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine.
* *
* @class SpineFile * @class SpineFile
@ -166,7 +166,7 @@ var SpineFile = new Class({
var currentPrefix = loader.prefix; var currentPrefix = loader.prefix;
var baseURL = GetFastValue(config, 'baseURL', this.baseURL); var baseURL = GetFastValue(config, 'baseURL', this.baseURL);
var path = GetFastValue(config, 'path', this.path); var path = GetFastValue(config, 'path', file.src.match(/^.*\//))[0];
var prefix = GetFastValue(config, 'prefix', this.prefix); var prefix = GetFastValue(config, 'prefix', this.prefix);
var textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); var textureXhrSettings = GetFastValue(config, 'textureXhrSettings');
@ -178,7 +178,7 @@ var SpineFile = new Class({
{ {
var textureURL = textures[i]; var textureURL = textures[i];
var key = 'SP' + this.multiKeyIndex + '_' + textureURL; var key = this.prefix + textureURL;
var image = new ImageFile(loader, key, textureURL, textureXhrSettings); var image = new ImageFile(loader, key, textureURL, textureXhrSettings);
@ -220,7 +220,7 @@ var SpineFile = new Class({
if (file.type === 'text') if (file.type === 'text')
{ {
atlasKey = file.key.substr(0, file.key.length - 2); atlasKey = file.key.replace(/_[\d]$/, "");
atlasCache = file.cache; atlasCache = file.cache;
@ -231,14 +231,14 @@ var SpineFile = new Class({
var src = file.key.trim(); var src = file.key.trim();
var pos = src.indexOf('_'); var pos = src.indexOf('_');
var key = src.substr(pos + 1); var key = src.substr(pos + 1);
this.loader.textureManager.addImage(key, file.data); this.loader.textureManager.addImage(key, file.data);
} }
file.pendingDestroy(); file.pendingDestroy();
} }
atlasCache.add(atlasKey, { preMultipliedAlpha: preMultipliedAlpha, data: combinedAtlasData }); atlasCache.add(atlasKey, { preMultipliedAlpha: preMultipliedAlpha, data: combinedAtlasData, prefix: this.prefix });
this.complete = true; this.complete = true;
} }

View file

@ -439,7 +439,7 @@ var SpinePlugin = new Class({
atlas = new Spine.TextureAtlas(atlasEntry.data, function (path) atlas = new Spine.TextureAtlas(atlasEntry.data, function (path)
{ {
return new Spine.canvas.CanvasTexture(textures.get(path).getSourceImage()); return new Spine.canvas.CanvasTexture(textures.get(atlasEntry.prefix + path).getSourceImage());
}); });
} }
@ -484,7 +484,7 @@ var SpinePlugin = new Class({
atlas = new Spine.TextureAtlas(atlasEntry.data, function (path) atlas = new Spine.TextureAtlas(atlasEntry.data, function (path)
{ {
return new Spine.webgl.GLTexture(gl, textures.get(path).getSourceImage(), false); return new Spine.webgl.GLTexture(gl, textures.get(atlasEntry.prefix + path).getSourceImage(), false);
}); });
} }