KanaX Posted August 18, 2017 Share Posted August 18, 2017 I'm fairly new to pixi.js and programming altogether. I am making a plugin that parses the xml save file of a sprite animation program and recreates the result in a game engine. The animation program uses bones for skeletal animations and the images (sprite parts) inherit the x, y, angle, scale_x, scale_y of the parent bone. The main idea would be to create sprites for the bones and the images, set up the bone inheritance to make the skeleton animation work correctly and then addChild the image sprites to the respective bone sprites. The only problem is that along with the aforementioned values, my image sprites also inherit the z_index of their container. The spriter does not limit the z hierarchy of the images to that of the parent bones, meaning that the user can change their z. I attempted to use worldTransform and worldAlpha for the parent bone values (keeping all the image sprites in a single container, thus controlling the z_index), but I am unable to get the parent bone's rotation. So, I either need to get all the values of the container and apply them correctly on the image sprites, or keep the image sprites inside the container and find a way to change their world z. Any suggestions would be appreciated and I thank you for your time. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 18, 2017 Share Posted August 18, 2017 Make bone structure separate, or just use https://github.com/pixijs/pixi-display/tree/layers (new branch of pixi-display) , it can sort elements in a subtree. As a first implementation it will work fine: you need to put a Layer container inside your object and assign all the attachments z-index and parentLayer. Also your stage must be PIXI.display.Stage, anyway look through examples. Then you can make separate structure of bones and transforms, like in https://github.com/pixijs/pixi-spine and https://github.com/EsotericSoftware/spine-runtimes/tree/3.6/spine-ts Quote Link to comment Share on other sites More sharing options...
KanaX Posted August 18, 2017 Author Share Posted August 18, 2017 @ivan.popelyshev Anything I can do without external files? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 18, 2017 Share Posted August 18, 2017 PIXI does not have any built-in sorting tools. Use "display" for first working version because its easy to do, then study spine code and implement same approach in your plugin. Quote Link to comment Share on other sites More sharing options...
KanaX Posted August 27, 2017 Author Share Posted August 27, 2017 @ivan.popelyshev After some tweaking and some help I managed to make your plugin work. Thank you for your help. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 27, 2017 Share Posted August 27, 2017 Good! Later, when you have enough time, you can figure out custom solution that'll be more performant. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.