This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by ArcadeHype

can anyone confirm if the following actually works:

if( this.currentAnim.loopCount > 0 ) {
	// played through at least once

i pulled this code from another post and was suggested by Dom but doesn't seem to work worth a shit.

i basically need to play through an animation once and then switch to a different animation and this code aint doin it. I also tried adding .rewind to my animation but that shit don't work either...very frustrating.

1 decade ago by mimik

it works.
Maybe you need to check for the correct animation first?
if you have a animation before your current animation you need to check the loopCount.

Show some code if you want more help.

1 decade ago by ArcadeHype

This is the code im using in my game:

this.currentAnim = this.anims.swipe;
if( this.currentAnim.loopCount > 0 ) {
	// played through at least once
	this.currentAnim = this.anims.walk;

i also tried appending .rewind to the following:
this.currentAnim = this.anims.swipe.rewind();

but doesn't make a difference.

is there something im missing?

1 decade ago by dominic

Where did you put that code? It should be in your entity's update() method - i.e. you need to check each frame "is this animation done yet"?

Edit: if you post code snippets, please use the ## symbols around your code. It will be easier to read with syntax highlighting and proper indentation. E.g.:

... your code

1 decade ago by ArcadeHype

yes its in the update method

1 decade ago by Joncom

Does the animation visually appear to be looping?

1 decade ago by PanTom

Did you inspect this.currentAnim with your debugger? Or are there any error messages in the javascript console? Can you post the sprite sheet used for this animation and the initialization code for the swipe-anim?
Page 1 of 1
« first « previous next › last »