komali2 Posted July 13, 2019 Share Posted July 13, 2019 I have the following JSON output of a spritesheet building tool: { "frames": { "Charge0.png": { "frame": { "x": 0, "y": 0, "w": 32, "h": 32 }, "rotated": false, "trimmed": false, "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, "sourceSize": { "w": 32, "h": 32 } }, "Charge1.png": { "frame": { "x": 32, "y": 0, "w": 32, "h": 32 }, "rotated": false, "trimmed": false, "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, "sourceSize": { "w": 32, "h": 32 } }, "Charge2.png": { "frame": { "x": 64, "y": 0, "w": 32, "h": 32 }, "rotated": false, "trimmed": false, "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, "sourceSize": { "w": 32, "h": 32 } }, "Charge3.png": { "frame": { "x": 96, "y": 0, "w": 32, "h": 32 }, "rotated": false, "trimmed": false, "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, "sourceSize": { "w": 32, "h": 32 } } }, "meta": { "app": "https://github.com/piskelapp/piskel/", "version": "1.0", "image": "data:image/png;base64,iVBORw....(etc)", "format": "RGBA8888", "size": { "w": 128, "h": 32 } } } I have the following code to load it: PIXI.Loader.shared .add('playerCharge', './assets/player-charge.json') .load((loader, resources) => { console.log(resources); //const animation = new PIXI.AnimatedSprite(resources.playerCharge.spritesheet.animations['image_sequence']); //console.log(animation); }); } According to the PIXIJS docs (which unfortunately don't give an example of what a valid JSON file should look like) https://pixijs.download/dev/docs/PIXI.AnimatedSprite.html , the resources instance (playerCharge) should have a spritesheet.animations property with some sort of named property in it. It does not. The animations object is empty. Therefore, I can't pass anything to AnimatedSprite. What's the right way to use this? Seems the only way is to manually iterate through the spritesheet.textures object, which is, strangely, populated. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 13, 2019 Share Posted July 13, 2019 There's no defined animations in that json. They have to be defined in TexturePacker itself. If you cant define it in editor, or you dont find what is json format for them, you have to use the code from pixijs example to convertt textures for animation. https://pixijs.download/dev/docs/packages_spritesheet_src_Spritesheet.js.html#line260 komali2 1 Quote Link to comment Share on other sites More sharing options...
komali2 Posted July 13, 2019 Author Share Posted July 13, 2019 Thanks for the reply Ivan. Any chance I could just manually append animation names in that JSON? What does a "valid" JSON look like? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 13, 2019 Share Posted July 13, 2019 yep. I don't know , that's why I gave you that piece of code. I also dont know how to trigget them from TexturePacker, maybe there's something in http://www.html5gamedevs.com/topic/40955-pixijs-spritesheet-tutorial/ Quote Link to comment Share on other sites More sharing options...
jonforum Posted July 13, 2019 Share Posted July 13, 2019 "animations": { "animationName": ["textureName","textureName"], "animationName": ["textureName","textureName"], }, 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.