Ninjadoodle Posted July 29, 2017 Share Posted July 29, 2017 Hi @enpu / guys Has anyone managed to get fromFrames working to make an animation in latest v2 dev? It looks like the function has changed to fromTextures - but I can't seem to get it working. Thank in advance! Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 Do you have any code example? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Hi @enpu Here is the code I'm trying ... (I've tried fromFrames and fromTextures). Mouse = game.Class.extend({ num: 0, blind: false, showing: false, init: function(x, y) { this.sprite = new game.Animation.fromFrames('mouseA'); this.sprite.addAnim('show', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) this.sprite.anims.show.speed = 60; this.sprite.anims.show.loop = false; this.sprite.addAnim('hide', [11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) this.sprite.anims.hide.speed = 60; this.sprite.anims.hide.loop = false; this.sprite.interactive = true; this.sprite.position.set(x, y); this.sprite.anchor.set(24, 32); this.sprite.addTo(game.scene.mg); } }); ... the only way I can get it to work, is to write up the frames/images individually. Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 Remove 'new' from that line and change to fromTextures: this.sprite = game.Animation.fromTextures('mouseA'); Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Hi @enpu I'm still getting ... Type Error - fromTextures is not a function Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 use fromTextures Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Sorry, yup I just tried from Textures but now its looks like it doesn't work in conjunction with addAnim Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 I'm getting ... typeError : undefined is not an object (evaluating this.sprite.addAnim') Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 Then there is probably no textures in cache starting with name 'mouseA'. Try console.log(game.Texture.cache); and see what you have there Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Hmmm ... I get when {} when I log the cache. What Im confused about is that this works ... Mouse = game.Class.extend({ num: 0, blind: false, showing: false, init: function(x, y) { this.sprite = new game.Animation([ 'mouseA0001.png', 'mouseA0002.png', 'mouseA0003.png', 'mouseA0004.png', 'mouseA0005.png', 'mouseA0006.png', 'mouseA0007.png', 'mouseA0008.png', 'mouseA0009.png', 'mouseA0010.png', but this doesn't Mouse = game.Class.extend({ num: 0, blind: false, showing: false, init: function(x, y) { this.sprite = game.Animation.fromTextures('mouseA'); Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 So those mouseA sprites are not in spritesheet? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Not in this case. Here they are single images (i'm having problems with the sprite sheets and @2x @4x etc. - they load at the wrong size - I posted on github) I can attach the project if you need. Quote Link to comment Share on other sites More sharing options...
enpu Posted August 1, 2017 Share Posted August 1, 2017 Yes that's the problem, it only works with textures from spritesheet. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 1, 2017 Author Share Posted August 1, 2017 Oh ok, sorry I didn't know that Thanks heaps for you help on this btw. I'll have to wait for a fix on the sprite sheet problem I'm having with @2x @4x sheets, as right now it breaks my level lol. If you need me to send you any test projects - please let me know! PS. Again - really appreciate the help! Quote Link to comment Share on other sites More sharing options...
enpu Posted September 12, 2017 Share Posted September 12, 2017 This should now work on all textures, not just on spritesheets. Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 12, 2017 Author Share Posted September 12, 2017 Nice! Thank you for that 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.