0

Web game code help

Problem: When I click right button after left button the square starts vibrating, please tell me what I should do before pasting the code pls Thanks in advance Here's my code: https://code.sololearn.com/WQyYYsJ5IDtU/?ref=app

10th Mar 2022, 4:10 PM
Rafin
Rafin - avatar
1 Answer
+ 1
https://www.w3schools.com/jsref/met_win_clearinterval.asp //edited Using your code as it you can clear the interval before you set interval, so you will be clearing the interval used in the lft() function before invoking the interval in the rght() function and vice versa. let intervalTimer; function strt() { clearInterval(intervalTimer) intervalTimer = setInterval(start, 64) } function rght() { clearInterval(intervalTimer) intervalTimer = setInterval(right, 64) } function lft(){ clearInterval(intervalTimer) intervalTimer = setInterval(left, 64) }
10th Mar 2022, 4:57 PM
ODLNT
ODLNT - avatar