AbdSab Posted December 16, 2014 Share Posted December 16, 2014 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 More sharing options...
XekeDeath Posted December 16, 2014 Share Posted December 16, 2014 Where are you putting the second snippet you posted...? Also, [code] tags instead of [quote] tags for code... AbdSab 1 Link to comment Share on other sites More sharing options...
ericjbasti Posted December 16, 2014 Share Posted December 16, 2014 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. AbdSab 1 Link to comment Share on other sites More sharing options...
AbdSab Posted December 16, 2014 Author Share Posted December 16, 2014 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 Link to comment Share on other sites More sharing options...
Recommended Posts