0

Canvas Is Not Updating [solved, i can't spell]

I am working on a clicker game in which a number updates every time a button is pressed. For some reason, however, I can't get the display to show the amount of clicks. I'm fairly sure my button detector is broken, but I can't be sure. Here is the code: (JS) ********************************************************************************************************** window.onload = function() { //setup let canv = document.getElementById("scorebox"); let btn = document.getElementById("clicker") let context = canv.getContext("2d"); let clicks = 0; btn.onlick = function() { clicks++; } function draw() { context.clearRect(0, 0, 400, 50); context.beginPath(); context.font = '40px Arial'; context.fillStyle = 'white'; context.fillText("Clicks: " + clicks, 130, 40); window.requestAnimationFrame(draw); } draw(); } ********************************************************************************************************** Please help!

27th Jan 2023, 5:26 PM
Benny H
Benny H - avatar
2 Answers
+ 2
I think, Mirielle means "save code and share link"!! instead of copy paste..
27th Jan 2023, 6:16 PM
Jayakrishna 🇼🇳
+ 1
Mirielle How do you provide a new code block here?
27th Jan 2023, 6:09 PM
Chris Coder
Chris Coder - avatar