Jump to content

How to replace arrow keys with wasd movement?


Recommended Posts

Hello Im new to Phaser.

I'd like to replace arrow keys with wasd keys

This is my code:

	this.cursors = this.input.keyboard.createCursorKeys();
	if (this.cursors.left.isDown) {
    } else if (this.cursors.right.isDown) {
    } else {
    if (this.cursors.up.isDown) {
      this.physics.velocityFromRotation(this.ship.rotation + 1.5, 100, this.ship.body.acceleration);
    } else {

Link to comment
Share on other sites

  • 1 month later...
On 12/1/2018 at 5:54 PM, robmuh said:

Just a vote for `createWASDKeys()` to compliment `createCursorKeys()`. It is certainly easy enough to add them, but would make beginner tutorials just a bit more concise.

The problem with something like this is that it's only useful for QWERTY keyboards, so a broader approach, like setting keys for each needed input seems to me like a better solution, even though that's a little more work.

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.

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.


  • Recently Browsing   0 members

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