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 auz1111

For some reason my animation stays at the last frame after playing, and I can;t get it to rewind.

hammerSwingAnimSheet: new ig.AnimationSheet( 'media/cali-hammer-swing.png', 125, 115 ),

this.hammerSwing = new ig.Animation( this.hammerSwingAnimSheet, 0.06, [0,1,2,3,4,5,6,7], true );

if (ig.input.pressed('punch') && !this.attacking && !this.jumping) {
				
				console.log("Punching..");
				
				this.tempDirection = this.direction;
				this.direction = 0;
				
                this.vel.x = this.vel.y = 0;
				
                this.currentAnim = this.hammerSwing.rewind();
				
				//console.log('Changing animationComplete to false...');
				//this.animationComplete = false;
				this.hammerSwing.rewind();
				this.hammerSwing.frame=0;
				
				this.currentAnim.rewind();
				
                this.action = "punch";
                this.isPunching = true;
                this.attacking = true;
				
                ig.game.sounds.bam.play();
				currentanimation = 3;

                // ig.game.sounds.swing.play();
            } else if (ig.input.released('punch')) {
				

                this.isPunching = false;
                this.attacking = false;
                
            }

//MOVE LEFT
				}else if( ig.input.state('left') && ismove != 1 && ismove != 2 && ismove != 4 && this.currentAnim.frame==0 ) {
					
					console.log("Moving left...");
}

Ultimately I am trying to figure out when the animation is finished and then allow the player to move left.

1 decade ago by alexandre

There's a great plugin for this. Check pointofimpact.com, under plugins, events. I use it all the time for a similar concept as yours and it works wonders.

1 decade ago by dominic

You can check .loopCount:
if( this.currentAnim.loopCount > 0 ) {
    // played through at least once
}

Not sure what&039;s going on with #.rewind() - it should work. Upload your game so we can have a look.

1 decade ago by auz1111

OK I will update this thread when I am able to upload the game, but for now the using loopCount has worked.
Page 1 of 1
« first « previous next › last »