Search the Community
Showing results for tags 'diagonal'.
-
Hi all, I'm making a shmup game at the moment. I'm trying to animate player's diagonal movements but can't get it to work. Any help you could offer would be greatly appreciated. First, I created the animation: this.anims.create({ key: 'rightUp', frames: this.anims.generateFrameNumbers('player', { start: 30, end: 33 }), frameRate: 10, repeat: -1 }); then when the player wants to go up&&right: if(this.keyLeft.isDown&&this.keyUp.isDown){ this.player.anims.play('rightUp', true); var isPaused = this.player.anims.currentAnim; var progress = this.player.anims.getProgress(); // console.log(isPaused) console.log(progress) } Everything else works perfectly fine (e.g. left, right, up, and down). My console just returns 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 when I press the up and left arrow at the same time. In contrast for any other motion, it returns the frame number it's playing. Thank you in advance, Bong
-
Abandoned.
- 8 replies
-
- 8 direction
- diagonal
-
(and 1 more)
Tagged with:
-
I am trying to move my player diagonally when I press down the 'up' & 'left' arrow keys. My current code is this this.moved = false; if (this.cursors.up.isDown) { this.moved = true; this.player.body.velocity.y -= 100; this.player.play('up'); } if (this.cursors.down.isDown) { this.moved = true; this.player.body.velocity.y += 100; this.player.play('down'); } if (this.cursors.left.isDown) { this.moved = true; this.player.body.velocity.x -= 100; this.player.play('left'); } if (this.cursors.right.isDown) { this.moved = true; this.player.body.velocity.x += 100; this.player.play('right'); } if (!this.moved) this.player.animations.stop();Now if I add the following if(this.cursors.left.isDown && this.cursors.up.isDown){ this.moved = true; this.player.play('upLeft');}and I press down the 'up' and 'left' keys, the player goes up (x=-100 & y=-100) which is what I want however, the animation does not work! It switches to the first frame of that animation but it stops after. So you will see a player sliding diagonally. It might be the "this.player.animations.stop()" that is getting in the way but I can't figure it out. Is there something I am not seeing?
-
Hi Im not sure if this is possible but for example if you hold the up and right arrow keys the player moves north east. Ive been trying to code this but just can't. Please Help Thanks.