xdiepx Posted March 3, 2014 Share Posted March 3, 2014 Hi all I am using the AssetLoader to load in multiple files which includes the json file. My question is how do i access the json data? This is because i want to use it to make an animation/spritesheet/movieclip. Here is an example code: var assetsLoader = ["star.json","star.png","bg.png"];loader = new PIXI.AssetLoader(assetsLoader );loader.onComplete = onAssetsLoadComplete; loader.load(); When I tried this code to add an animation: var star= new PIXI.Spine("star.json"); I get this error message: Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader:star.json I am not sure what is wrong there, so i gave up and thought and try adding a movie clip animation using the movieclip example from http://www.goodboydigital.com/pixijs/examples/3/. For you to get the frames you have to do a loop like this: for (var i = 0; i < 26; i ++){ var texture = PIXI.Texture.fromFrame("Explosion_Sequence_A " + (i+1) + ".png"); explosionTextures.push(texture);} Because i want to use the json to loop around and add the frame name: (example) var jsonData = star.jsonfor(var i =0; i < jsonData.length; i ++){ var texture = PIXI.Texture.fromFrame(jsonData.frameName + ".png"); explosionTextures.push(texture);} Any help would be great Thank you. p.s I am using ShoeBox and not texture packer to create my spritesheet not sure if that has anything to do with the spine problem. xdiepx 1 Quote Link to comment Share on other sites More sharing options...
enpu Posted March 3, 2014 Share Posted March 3, 2014 Try changing your Spine animation to .anim Quote Link to comment Share on other sites More sharing options...
xdiepx Posted March 3, 2014 Author Share Posted March 3, 2014 Hi Enpu, Thank you for responding. I have tried that and it gave me the same result:Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader:star.anim. So I am not sure what I am doing wrong. I wonder if PIXI have a getJSON function in the assetLoader. It would actually be nice to have a getJson or getXml function. Quote Link to comment Share on other sites More sharing options...
mim Posted March 8, 2014 Share Posted March 8, 2014 there is jsonLoader function you may use diep: http://www.goodboydigital.com/pixijs/docs/files/src_pixi_loaders_JsonLoader.js.html# Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.