1 decade ago by Gamma
I've been trying hard to make it so that my character can shoot with a different animation while at the same time standing. I don't want my character just standing and shooting randomly. I'll be making animations for running while shooting and standing while shooting, but how do I implement the shooting animations for running and standing.
I tried adding;
[Update Function]
But it doesn't show the animation at all. If you guys want to know how I have my stuff set up here it is below.
[Update Function]
Thank you all in advance.
I tried adding;
[Update Function]
if(this.standing && ig.input.pressed('shoot')) { this.currentAnim = this.anims.standshooting; }
But it doesn't show the animation at all. If you guys want to know how I have my stuff set up here it is below.
[Update Function]
/ move left or right var accel = this.standing ? this.accelGround : this.accelAir; if( ig.input.state('left') ) { this.accel.x = -accel; this.flip = true; }else if( ig.input.state('right') ) { this.accel.x = accel; this.flip = false; }else if( ig.input.state('backwards') ) { this.accel.x = -accel; this.flip = false; }else{ this.accel.x = 0; } // jump if (ig.input.pressed('jump') && this.standing) { this.vel.y = -this.jump; this.jumpX = 1; } if (ig.input.state('jump')) { this.vel.y -= this.jump*0.1*this.jumpX; this.jumpX = (this.jumpX > 0.1 ? this.jumpX*0.89 : 0); } // shoot if( ig.input.pressed('shoot') ) { ig.game.spawnEntity( this.activeWeapon, this.pos.x, this.pos.y, {flip:this.flip} ); } if( ig.input.pressed('switch') ) { this.weapon ++; if(this.weapon >= this.totalWeapons) this.weapon = 0; switch(this.weapon){ case(0): this.activeWeapon = "EntityPistol"; break; case(1): this.activeWeapon = "EntityDouble"; break; } this.setupAnimation(this.weapon); } // set the current animation, based on the player's speed if( this.vel.y < 0 ) { this.currentAnim = this.anims.jump; }else if( this.vel.y > 0 ) { this.currentAnim = this.anims.fall; }else if( this.vel.x > 0 ) { this.currentAnim = this.anims.run; }else if( this.vel.x < 0 ) { this.currentAnim = this.anims.run; }else{ this.currentAnim = this.anims.idle; } this.currentAnim.flip.x = this.flip; // move! this.currentAnim.flip.x = this.flip; if( this.invincibleTimer.delta() > this.invincibleDelay ) { this.invincible = false; this.currentAnim.alpha = 1; } this.parent(); },
Thank you all in advance.