Jump to content

Loading multiple files with AssetLoader and acessing json file


xdiepx
 Share

Recommended Posts

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.json
for(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. 
 
 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...