Hello,
I’m trying to dynamically create Spine animations from code, by downloading the files from a server (remote loading, cc.loader.load to download files), I won’t be able to add these animations in my resources folder or anywhere in the project because we want to add more animations later without force updating the app on the store.
However the problem is that each file is being downloaded in different folders with different names, and apparently spine can’t find the texture atlas, cause I get this error:
Failed to load spine atlas '$s' shop.png
As you can see, it seems that the texture has no name in the json file. And then spine fails to load the atlas by giving this error the next line:
Uncaught TypeError: Cannot read property 'setFilters' of null at TextureAtlas.288.TextureAtlas.load (spine.js:4850)
Any workarounds for this?
Can you actually load spine animations dynamically?
Is there a way to put all these spine files into a single folder after downloading them so atlas can find the texture?
Any help would be appreciated. Thanks.
Here is the full code that I’m using, just in case (File addresses are fake, I save these files on our server):
let atlas = "http://test.com/shop.atlas";
let json = "http://test.com/shop.json";
let texture = "http://test.com/shop.png";
cc.loader.load([atlas, json, texture], (err, results) => {
let data = new sp.SkeletonData();
data.textures.push(results.getContent(texture));
data.atlasText = results.getContent(atlas);
data.skeletonJson = results.getContent(json);
this.skeleton.skeletonData = data;
this.skeleton.setAnimation(0, 'Dice_Right', true);
});