Animation Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Animation Question

I'm developing a paddleball game but the button to move the paddle. I've put the animation in a function and called it with onclick but it still won't work. Can you help? Thanks!

8th Mar 2017, 2:19 PM
Caleb Jore
Caleb Jore - avatar
2 Answers
+ 9
<!-- Sure. Here is the HTML: --> <button id="button_right" class="buttons" onclick="moveRight">&#12297;</button> // And here is the JS: var pos; function moveRight() { pos += 100; paddle.style.left = pos + "px"; setInterval(moveRight, 50); } // Thanks ahead of time!
9th Mar 2017, 2:06 PM
Caleb Jore
Caleb Jore - avatar
+ 4
Can you paste the animation code for reference? I'll be able to help you more if I can see what we have to work with :)
8th Mar 2017, 3:20 PM
Lux
Lux - avatar