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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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