Jump to content

Mobile Swipe Movement


gen10do
 Share

Recommended Posts

Hello All, 

And thank you in advance for any assistance. I am trying to make a shoot em up for mobile where as players "slide" or "swipe their finger on their screen it moves the player character. There are several shooters that can be found on the Google Play Store. Mostly of the top down scroller space shooter variety.

Currently I am able to make it so that the player character sprite will follow the players finger or thumb when they "slide" or "swipe" on their screen with the following code:

if (!this.player.getData("isDead")) {
    this.input.on('pointermove', function (pointer) {
        this.player.x = pointer.x + 80;
        this.player.y = pointer.y;
        this.player.setData("isShooting", true);
    }, this);
}

This works pretty smoothly in the update function of the update function of the phase 3 game loop. However, I would like for players to be able to have the option of controlling their character a different way where the player character sprite does not track to the players finger or thumb, but rather to move the sprite from it's current position independent of where the player's finger starts and finishes  it's "swipe" or "slide".

Is there a simple way to do this?

Any help would be greatly appreciated.

Thank you.

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...