1 decade ago by Gamma
Hello everyone, recently I've been thinking of making the character go backwards as an in-game tactic, but I've been having trouble with that. First I made a little bit of code in the Main.js file.
Then I continued on, and added a strip of code to the player.js file, like so [Under the init function,].
But my problem is, how would I make it so that when the user presses on the Z key, the player would move backwards (left) on the screen. I currently was able to make it flip backwards, but the animation wouldn't show up.
This is what I added to make it flip, but no animation showed up. [Under the update function]
[EDIT]
Ok, so I got it to work so that when the user presses Z the player moves left, BUT the animation won't show.
ig.input.bind( ig.KEY.Z, 'backwards');
Then I continued on, and added a strip of code to the player.js file, like so [Under the init function,].
this.addAnim( 'defense', 0.07, [16,17]);
But my problem is, how would I make it so that when the user presses on the Z key, the player would move backwards (left) on the screen. I currently was able to make it flip backwards, but the animation wouldn't show up.
This is what I added to make it flip, but no animation showed up. [Under the update function]
// Moving Backwards (Defense tactic) var accel = this.standing ? this.accelGround : this.accelAir; if( ig.input.pressed('backwards') ) { this.accel.x = -accel; this.flip = true;
[EDIT]
Ok, so I got it to work so that when the user presses Z the player moves left, BUT the animation won't show.
var accel = this.standing ? this.accelGround : this.accelAir; if( ig.input.state('backwards') ) { this.accel.x = -accel; this.flip = true; }