+ 1
How to hold control flow until an event is fired?
I want the game to continue only after i tap on the displayed element. Using tap=0; Elem.onclick=()=>{tap=1;} while(!tap){} is not working.
9 Respuestas
+ 2
https://code.sololearn.com/Wyx5cwbfdo2U/?ref=app
https://code.sololearn.com/WCuCQxbO6dZr/?ref=app
the first is by using tap as control flow, you can easily implement pause button
the second by directly start the loop in listenter, more straightforward approach
+ 1
I want startOverlay() to hold until user taps.
https://code.sololearn.com/WBOm4adsUrE1/?ref=app
+ 1
Can't i hold on to line 125 until click event is found?
+ 1
And won't the above idea just start/end the game instead of holding the control flow?
+ 1
I really can't understand.
+ 1
Thankyou very much 🤗
0
use if(!tap) inside the game loop.
0
add new global variable for the game switch
var gameswitch = false;
in main() check if the gameswitch is true to continue
if(!gameswitch) return;
now you can modify the gameswitch value from somewhere else to control (start/suspend) the game flow, in your case in startOverlay screen
0
to start ? then just put setInterval inside the overlayListener