Jump to content

Mobile Tutorials or Examples


ShadowMoon
 Share

Recommended Posts

Are there any good examples or tutorials for swipes and touch/ tap events for Phaser 3.  I am new to game development. I did this tutorial for phaser 3, played around with it, added sounds and such. But the next thing I wanted to do was try and port it to Android. I was able to get most of the look right, but for the life I me I can't figure out how to get the 'dude' to move!!! Any help would be appreciated. Thanks

Link to comment
Share on other sites

Thanks for the video! He covers a lot on keystrokes and mouse input, but there still is nothing on mobile touch (taps / swipes). I am able to use hammer.js to detect swipes, but incorporating it into the update function is where I'm getting stumped for now. I'm pretty sure there is a way to handle touch events with just Phaser 3 which would be ideal.

Link to comment
Share on other sites

Hey samme, thanks! I was kind of looking at these. And this snippet will move the dude one little frame at a time:

            this.input.on('pointerdown', function(){
                player.setVelocityX(-160);            
                player.anims.play('left', true);                
            }, this);

but how can I get the update function to check if pointer is down, similar to what I'm able to do with the cursor keys? This is the example from the tutorial and it makes the dude run left.

        if (cursors.left.isDown)
        {
            player.setVelocityX(-160);

            player.anims.play('left', true);
        }

 

Link to comment
Share on other sites

Got it! Thanks everyone. I just made a variable moveLeft, set it to false. Then on the pressdown event changed it to true and have the if statement in update check the state. On tap, he hauls ass to the left :) Now the easy part of getting him moving left, right, and jumping. 

var moveLeft = false;

function create(){
          this.input.on('pointerdown', function(){
                moveLeft = true;
            }, this);
}

function update(){
        if (moveLeft)
        {
            player.setVelocityX(-160);

            player.anims.play('left', true);
        }
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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