Jump to content

Tap and hold event in


ritsrivastava
 Share

Recommended Posts

I created a mobile app using phaser JS and used keyboard key (up/down/right/left) to move my player (hero) and it is working fine

 

eg:

if (cursors.up.isDown) {

player.body.velocity.y = -100;
}

hero is moving upward smoothly on press and hold the up key 

 

when i used the button for moving the player up/down/right/left :

 

game.add.button(0,0,'btnUp',function(){
player.body.velocity.y = -400;

},this); 

I have added  function on click.. but for moving the player I need to press that up button again and again , there is no such 'HOLD' .

Also pressing again and again the button player is not moving smoothly..

 

 

Can some one help me that how can i move the object (Player) on hold the button..

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