Jump to content

Keyboard and Numpad inconsistancy (Phaser cursor controls)


algut20
 Share

Recommended Posts

Hello guys, I am new to Phaser and programming in general. I encountered a problem while setting up the cursor controls for my player. The idea is for the player to shoot a bullet in the direction the player is pointing or running to, even while jumping. If i press the right-key and up-key at the same time and fire a bullet, everything works just fine. However, if I press the left-key and up-key at the same time and fire a bullet, the bullet does not fire.

 

What is interesting is that If I hold the left-key and up-key at the same time and fire the bullet, the bullet fires, working just fine using the Numpad on the very same keyboard. So I thought I had a faulty keyboard and tried a different one, but I came up with the same results. Since I am new to Phaser, I am wondering If I am not doing something correctly? It would be nice to be able to use the specified key arrows instead of the numpad. For those interested, this is the part of the code that deals with the cursor mechanics (again, this code works just fine on the numpad):

 

if (this.cursors.left.isDown)
      {
       if(this.fireButton.isDown){ this.fireBulletLeft();}
       this.player.body.velocity.x = - 150;  this.player.animations.play('left');
      }
       
if (this.cursors.right.isDown)
      {
      if(this.fireButton.isDown ){ this.fireBulletRight();}
      this.player.body.velocity.x = 150;this.player.animations.play('right');
      }
 
if (this.cursors.up.isDown && this.player.body.touching.down)
      {
      this.player.body.velocity.y = -350;
      }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...