Why isn't my ball moving? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why isn't my ball moving?

window.onload = function(){ let btn = document.getElementById("jump"); let count = 0; document.ontouchstart = function(){ count += 1; y -= 25; } function draw() { context.clearRect(0, 0, 600, 400); context.beginPath(); context.arc(x, y, 50, 0, 2 * Math.PI); context.fillStyle="red"; context.fill(); context.font = '25px Arial'; context.fillStyle = 'white'; context.fillText("Count: " + count, 20, 30); window.requestAnimationFrame(draw); } var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); var x = 300; var y = 350; context.arc(x, y, 50, 0, 2 * Math.PI); context.fillStyle="red"; context.fill(); }

13th Apr 2022, 4:01 PM
Nate Washburn
2 Answers
+ 3
you didn't call the function draw() ; change text color to something other than white to be visible. https://code.sololearn.com/WYa3T1tOmLnk/?ref=app
13th Apr 2022, 4:23 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 3
Thank you Bahha!
13th Apr 2022, 4:32 PM
Nate Washburn