Jump to content

Playing animation from certain frame, then loopong


mraak
 Share

Recommended Posts

Can I play the animation starting from random frame, and then loop?

 

Say I have 20 frames. I want to start from 8th, continuing to 20, and then loop from 1st all the way to 20th and so on. 

 

This doesn't seem to do anything:

animations.frame = 8;animations.play("all");
Link to comment
Share on other sites

Does it work if you use setFrame(8) instead of animation.frame=8?

 

Do you need the animation to always start from the same frame? You could create it starting from there with animations.add('all', [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7], fps, true);

Link to comment
Share on other sites

No it should start from arbitrary frame. I was thinking of constructing 20 arrays but it seems like an overkill.

 

And setFrame throws an error like the function isn't even there

hero.animations.setFrame( _.random(0,45));

Uncaught TypeError: undefined is not a function

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

I cannot figure it out, how did you get it to work?

I get an error, setFrame is not a function.  And then if i default.setFrame it says cannot read setframe of undefined

Phaser.Sprite.call(this, game, getRandom(0, game.world.width), getRandom(0, game.world.height), 'spJellyFish');
	this.animations.add('default');   
	this.animations.play('default', 30, true);
	this.animations.setFrame(getRandom(0, 20), true);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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