Ninjadoodle Posted January 28, 2018 Share Posted January 28, 2018 Hi @enpu I'm having a bit of a problem loading an animation from an atlas. Some of the frames seem to play out of order. This is the code I'm using to load my anim ... game.createClass('S04Bunny', { init: function(x, y) { this.anim = game.Animation.fromTextures('s04BunnyA'); this.anim.position.set(x, y); this.anim.anchorCenter(); this.anim.speed = 5; this.anim.play(); this.anim.addTo(game.scene.mg); } }); Thanks in advance Quote Link to comment Share on other sites More sharing options...
enpu Posted January 28, 2018 Share Posted January 28, 2018 @Ninjadoodle Can you show how have you named all the textures with name 's04BunnyA' ? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted January 28, 2018 Author Share Posted January 28, 2018 Hi @enpu There are named ... s04Bunny0.png, s04Bunny1.png, s04Bunny2.png ... all the way to 20 Quote Link to comment Share on other sites More sharing options...
enpu Posted January 28, 2018 Share Posted January 28, 2018 I think i found the issue. The native JavaScript's sort function doesn't seem to work as i thought. For example when sorting array with it number 10 comes before number 2, and that's why the animation order is not working properly. But i found a fix for that and just pushed changes to dev branch. Let me know if it works now! Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted January 28, 2018 Author Share Posted January 28, 2018 Hi @enpu Perfect! Thanks heaps Just a quick question ... how can I load frames 1 to 10 for example? I've tried this.anim.addAnim('show', [0, 10]) which only shows 0 and 10 and this.anim.addAnim('show', [0..10]) which doesn't work lol Quote Link to comment Share on other sites More sharing options...
enpu Posted January 28, 2018 Share Posted January 28, 2018 That second parameter is array of all invidual frames, so you need [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted January 28, 2018 Author Share Posted January 28, 2018 Ok cool, I though there might have been a shortcut if you have lots of frames. All good, that's easy enough Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted January 28, 2018 Share Posted January 28, 2018 @Ninjadoodle I just modified the addAnim function, so you can also define start frame and number of frames, instead of frames array: // Animation with array of invidual frames anim.addAnim('jump', [3, 4, 5, 6]); // Animation with 4 frames starting from frame 3 anim.addAnim('jump', 3, 4); Can you test if it works? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted January 28, 2018 Author Share Posted January 28, 2018 Hi @enpu Awesome it works, but there is one issue. You can’t start with frame 0. I tend to start my naming with 0 because of how js works. Quote Link to comment Share on other sites More sharing options...
enpu Posted January 28, 2018 Share Posted January 28, 2018 @Ninjadoodle Can you try now again Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted January 28, 2018 Author Share Posted January 28, 2018 Perfect 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.