1 decade ago by Wrolf
Hi, I'm a little confused about the pressed and state function as I'm trying to build a top down 4 direction grid movement but want it so if the key is "pressed" once, the player wouldn't move but just face that direction until the key is held down.
I've tried several different ways but this one made the most sense to me but didn't work. Tried looking at some examples but none of them does what I want. Any pointers would be greatly appreciated.
player.js
I've tried several different ways but this one made the most sense to me but didn't work. Tried looking at some examples but none of them does what I want. Any pointers would be greatly appreciated.
player.js
if (ig.input.pressed('up')){ this.currentAnim = this.anims.idleup; }else if(ig.input.state('up')) { this.vel.y = -this.speed; this.vel.x = 0; this.colliY = this.pos.y.round() - this.colliSize; this.direction = "up"; this.currentAnim = this.anims.up; }