onedkr Posted February 15, 2015 Share Posted February 15, 2015 Hello,I've some problems with basics animation on phaser 2.2.2 : I created an animation : game.load.atlas('bodyPlayer', 'img/body.png', 'data/body.json');...player = game.add.group();player.health = 100;game.physics.arcade.enable(player);player.enableBody = true;bodyPlayer = player.create(140, GAME_HEIGHT - 255, 'bodyPlayer');bodyPlayer.animations.add('normal', [0,1]);bodyPlayer.animations.add('run', [2,3,4]);After in the update function :bodyPlayer.animations.play('run', 5);console.log(bodyPlayer.animations.name);console.log(bodyPlayer.animations.currentFrame.name);Here the result : main.js:190 runmain.js:191 003 - run1.pngmain.js:190 runmain.js:191 004 - run2.pngmain.js:190 runmain.js:191 005 - run3.pngmain.js:190 runmain.js:191 Uncaught TypeError: Cannot read property 'name' of undefined It made one loop, display correctly the names of all the frames of this animation, stop and show this error. I attach my Json File made with Texture packer (Json Array). Thank you for your answer and sorry for my english :/ Link to comment Share on other sites More sharing options...
onedkr Posted February 16, 2015 Author Share Posted February 16, 2015 Up ? Sorry I searched on google and in the docs during long time, but I didn't find the solution.I don't know why the attribute currentFrame is null ... Link to comment Share on other sites More sharing options...
onedkr Posted February 17, 2015 Author Share Posted February 17, 2015 I found the solution if someone have the same problem ... I just forget the parameter true in the method play :bodyPlayer.animations.play('run', 5, true); Link to comment Share on other sites More sharing options...
Recommended Posts