Jump to content

Input probleme


AbdSab
 Share

Recommended Posts

Hi all i have another problem

 

I want to know how to do a function in loop while touching on the screen

 

i tried

 

 

this.game.input.onDown.add(this.fly,this);

 

and

 

 

 

if (this.game.input.isDown == true){this.fly();}

 

but the function is executed jump one time is there any solution ??

 

And thank's :)

Link to comment
Share on other sites

not sure why you want to fire a fly function over and over again based on an event being down. You should probably look at it this way. When the button is pressed set flying = true, when the press is done set flying = false. Your main loop will look for flying == true and make the character fly or whatever its suppose to do. Mouse and touch events can fire more or less times than the main loop because the browser is running them separately.

Link to comment
Share on other sites

 

Where are you putting the second snippet you posted...?

 

Also, [code] tags instead of [quote] tags for code...
 

I'm sorry i didn't pay attention to this i will fix, thank you :)

 

 

 

not sure why you want to fire a fly function over and over again based on an event being down. You should probably look at it this way. When the button is pressed set flying = true, when the press is done set flying = false. Your main loop will look for flying == true and make the character fly or whatever its suppose to do. Mouse and touch events can fire more or less times than the main loop because the browser is running them separately.

 

Thank you for very much it work fine now  :D

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