Jump to content

Problem loading atlas


MouseCaneta
 Share

Recommended Posts

I'm trying to load an atlas created with TexturePacker using:

PIXI.loader
   .add("game", "assets/sprites/game.json")
   .add("ui", "assets/sprites/ui.json")
   .on("progress", loadProgress)
   .load(setup);

But for some reason pixi seems to be indexing the loaded assets by incremental numeric id instead of using the labels contained in the respective json files. Because of this I'm getting index collision when loading more than one atlas. Anyone know why?

Another question, how hard it is to write a custom loader. I'm trying to import animations from ToonBoom which uses a specific xml format. I want to load it automatically as with the TexturePacker atlas.

Link to comment
Share on other sites

There was an issue about indexing but didnt give any details on it. Your issue also does not contain any necessary info to replicate it. You can look at https://github.com/pixijs/pixi.js/blob/dev/src/core/textures/Spritesheet.js#L158 , "i" is certainly a key and not an index.

JSON parser is inside Spritesheet class, you have to do your own Spritesheet and loader for it, its not a big deal comparing to creation of your own renderer plugin or a filter :)

Link to comment
Share on other sites

Found out what the problem was about the indexing, seems like the exported atlas I was using was published in the Phaser format instead of the Pixi one. I knew that actually, but I wrongly assumed they would be the same since Phaser uses Pixi.

Are there any guidelines for writing custom loaders? Anywhere I can read about?

Link to comment
Share on other sites

Pixi using this lib: https://github.com/englercj/resource-loader , you can pester @xerver about examples :)

No, actually, its easier to just look up the code and do the same thing. https://github.com/pixijs/pixi.js/blob/dev/src/loaders/spritesheetParser.js

Just make a middleware and use() it, you have to submit a function that processes resource. SpritesheetParse is a factory that returns that kind of function, please make sure you understand that you need submit a function and not the factory :)

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...