Jump to content

Accessing json files loaded via AssetLoader


Sebi
 Share

Recommended Posts

Hi guys,

 

I didn't look it up yet but I am curious if there is a way to access json data loaded via AssetLoader e.g.

 

I have a spritesheet and I am loading it via PIXI.

 

PIXI.AssetLoader(["spritesheet.json", ...]);

 

Is that json file somewhere stored within PIXI or could you guys add the AssetData as argument to the onComplete?

 

var loader = new PIXI.AssetLoader(['spritesheet1.json', 'spritesheet2.json']);

loader.onComplete = function(assets) {

 console.log(assets['spritesheet1.json']);

};

loader.load();

 

Because sometimes I might want to know what was loaded. Imagine an Map Editor.

1. Create a Map

2. Pick a Tileset for that map.

3. Request Tileset via PIXI

4. Request Tileset via jquery

5. Display available Tiles in DOM

 

Or the other way around would work too (if you dont want to add an callback), but this approach would lack async loading because the json would have been loaded first before calling the assetloader.

 

1. Request tileset via jquery

2. Pass json to PIXI asset loader <- in that case pixi would have to check if one of the asset urls is an object, if so -> create textures. if its a string -> do the regular stuff.

 

Just curious.

Cheers.

Link to comment
Share on other sites

Another thing that came to my mind:

 

If I have a spritesheet for each character class / npc / mob / whatever, would it be possible to reuse the json file for that spritesheet but with different skins (image)?

That would reduce the amount of requests a lot.

 

"spritesheet.json"

-> "spritesheet1.png" -> Frames: spritesheet1_1.png, spritesheet1_2.png, spritesheet1_3.png
-> "spritesheet2.png" -> Frames: spritesheet2_1.png, spritesheet2_2.png, spritesheet2_3.png
 
Just for the case that you have a lot spritesheets that always follow the same pattern. 
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...