Search the Community
Showing results for tags 'currentFrame'.
-
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 :/
- 2 replies
-
- Json Array
- atlas
-
(and 1 more)
Tagged with:
-
Hi: I have a sprite loaded as atlasJSONArray. I can create serveral versions of the animation and start playing it back like this: for( var x = 0; x < 800; x = x+100){ for(var y = 0; y < 600; y = y+100){ var cat = game.add.sprite(x, y, 'cat'); cat.animations.add('run'); cat.animations.play('run', 30, true); } }what Im trying to achive now is let every instance to start at a random frame (to make all animations look different). i tried this but does not work: cat.animations.frame = Math.floor(Math.random() * cat.animations.frameTotal); how could this be done? I'm as3 coder so I used to do sprite.gotoAndPlay(someFrame);thks !