Sign in to follow this  

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 {

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.