Jump to content

Share single Spine atlas for multiple animations?


d13
 Share

Recommended Posts

Hi Everyone, 

Another Spine question: Is it possible for many Spine animations to share one texture atlas? For example, I have some animations that look like this:

animationOne.json

animationTwo.json

animationThree.json

My atlas and PNG look like this:

myAnimation.png

myAtlas.png

I basically need my three animations to share the same .png and .atlas files

I have read this, https://github.com/pixijs/pixi-spine/blob/master/examples/reuse_texture.md, but I'm not sure whether it applies to this use case..? (If it does, please let me know!)

Thank, you!

Link to comment
Share on other sites

That's something I can clarify.

Yes, it applies to your case , and that's one of the ways to do it.

Another is to load json's without spine loader, and manually create all SpineData's passing the same atlas around. The problem is that there's no way to specify loader API to NOT use particular loader, and I really don't want to explain how to hack it because, well, its better to spend that time later on actual loader patch.

Edited by ivan.popelyshev
Link to comment
Share on other sites

Thanks Ivan!

I'm having a little trouble understanding how this might work. In this example...

 

var atlasLoaderOption = { metadata: { imageNamePrefix: 'spineAtlas_' } };

PIXI.loader

    .add('flyingAnimation.json', spineLoaderOptions);

    .add('walkingAnimation', spineLoaderOptions);

    .add('anotherAnimation.json', spineLoaderOptions);

... will my JSONs need to have the same root name for them to share the single atlas and png?

Link to comment
Share on other sites

You need the same name of atlas inside those "json" files.

There's nothing to understand before you actually run it - then you get result, debug it, understand whats went wrong. There's no theory in loaders, they all have hacks to support several ways people use. If new way is discovered - its added in loader and in docs.

I really hope that someone will make alternative loader that wont be that hacky.

Edited by ivan.popelyshev
Link to comment
Share on other sites

Just for reference, I finally managed to get this working by duplicating the atlas files for as many JSON files as I have (15), giving them the same name as the JSON, and pointing the atlas to the same single PNG file. I'm getting the error message, "BaseTexture added to the cache with an id [assets/animations/observation/observation.png] that already had an entry", but I can live with that for now. If I find a better, less hacky, way to do this, I will report back ?

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