Jump to content

diex
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...