Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading assets inline #54

Closed
daviestar opened this issue Sep 10, 2015 · 2 comments
Closed

Loading assets inline #54

daviestar opened this issue Sep 10, 2015 · 2 comments

Comments

@daviestar
Copy link

Is it possible to not use the PIXI loader for assets, or somehow sidestep the ajax call?

I've tried to cut out the delay in the data loading over ajax by inlining the JSON object and atlas from Spine, but I can't get it to work.

Thanks.

@ivanpopelyshev
Copy link
Collaborator

I looked at atlasParser.js and wrote this:

var rawSkeletonData = JSON.parse("$jsondata"); //your skeleton.json file here
var rawAtlasData = "$atlasdata"; //your atlas file 

var spineAtlas = new spine.Atlas(rawAtlasData, "pathToAtlasImage/"); //specify path, image.png will be added automatically

var spineJsonParser = new PIXI.spine.SkeletonJsonParser(new PIXI.spine.AtlasAttachmentParser(spineAtlas));
var skeletonData = spineJsonParser.readSkeletonData(rawSkeletonData);

//now we can create spine instance
var spine = new PIXI.spine(skeletonData);

if your atlas textures wasnt preloaded I recommend to copy part that use "async.each" too.

Please test this code and tell me if it works for you.

@daviestar
Copy link
Author

Thanks @ivanpopelyshev !

Below is what worked for me:

var rawSkeletonData = {
  "skeleton": { ... },
  "bones": [ ... ],
  "slots": [ ... ]
};

var rawAtlasData = 'test.png\nsize: 482,310\nformat: RGBA4444\nfilter: Linear,Linear\nrepeat: none\ndude/arm left hand\n rotate: false\n xy: 430, 30\n size: 19, 32\n orig: 21, 34\n offset: 1, 1\n index: -1\n...';

var spineAtlas = new PIXI.spine.SpineRuntime.Atlas(rawAtlasData, 'img/spine');

var atlasAttachment = new PIXI.spine.SpineRuntime.AtlasAttachmentParser(spineAtlas);

var spineJsonParser = new PIXI.spine.SpineRuntime.SkeletonJsonParser(atlasAttachment);

var skeletonData = spineJsonParser.readSkeletonData(rawSkeletonData);

var dude = new PIXI.spine.Spine(skeletonData);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants