Impact

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

1 decade ago by Hazneliel

In the documentation it says:

.rewind()

Rewinds the animation to its first frame and resets the .loopCount

This method returns the animation itself. This is useful when switching between animations. E.g:

// In an entities .update() method
this.currentAnim = this.anims.jump.rewind();

But if I do like this in the update method, everytime it plays the frame 0, since each call to the update method is rewinding the animation to the first frame 0.

What do you think? where I have to rewind it?

1 decade ago by namuol

It sounds like you&039;re calling #rewind() every frame. Could you post the entirety of the update function?

1 decade ago by Hazneliel

update: function() {
               
				this.currentAnim = this.anims.idle.rewind();
				this.parent(); 			  
            },

Just as the documentation says in the example: http://impactjs.com/documentation/class-reference/animation#rewind

1 decade ago by neogope

In this case you would 'rewind' the animation with every frame. Try something like this:

	update: function() {
		this.parent();
		if (this.condition) {
			this.currentAnim = this.anims.idle.rewind();
			this.condition = false;
		}
	}

1 decade ago by Hazneliel

Thats exactly what Im saying...

So the documentation is wrong

1 decade ago by neogope

I wouldn't say it is wrong, as it definitely is IN the update function ;)

Everybody has other conditions to call this function (could be a timer, could be a flag, a combination of both, only on frame X) and I think to cover them all in a Class Reference would be way too much.
Page 1 of 1
« first « previous next › last »