diex Posted January 27, 2014 Share Posted January 27, 2014 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 ! Link to comment Share on other sites More sharing options...
grimor Posted January 27, 2014 Share Posted January 27, 2014 I think you should first get specific animationcat.animations.getAnimation('run').frame = Math.floor(Math.random() * car.animations.getAnimation('run').frameTotal); Link to comment Share on other sites More sharing options...
diex Posted January 28, 2014 Author Share Posted January 28, 2014 got it !kind regards ! Link to comment Share on other sites More sharing options...
Recommended Posts