Please, how can I improve the buttons(touchhold) to move ball | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please, how can I improve the buttons(touchhold) to move ball

https://code.sololearn.com/WRRox30DY48z/?ref=app

2nd Aug 2020, 12:01 AM
Abat
Abat - avatar
4 Answers
+ 4
Here’s an example I put together: https://code.sololearn.com/W6FcoiC6zs1q/?ref=app
2nd Aug 2020, 4:24 AM
Rowsej
Rowsej - avatar
+ 4
While a joystick might be good, buttons still work, like in this game by Jingga Sona: https://code.sololearn.com/We2Y51lGO5YO/?ref=app You can use setInterval() and clearInterval() to make it move left or right again and again, multiple times a second.
2nd Aug 2020, 3:07 AM
Rowsej
Rowsej - avatar
+ 2
Abat I think a joystick would me much better. Joystick to move the ball horizontally.
2nd Aug 2020, 2:39 AM
Hanuma Ukkadapu
Hanuma Ukkadapu - avatar
+ 2
Abat See this game created by Rowsej which uses a joystick. Implement something similar to this to move the ball only in horizontal direction. https://code.sololearn.com/WaOeV41d37b3/?ref=app
2nd Aug 2020, 2:42 AM
Hanuma Ukkadapu
Hanuma Ukkadapu - avatar