+ 2
1st Jan 2022, 9:01 PM
MrTobeDaBull
MrTobeDaBull - avatar
32 Respuestas
+ 2
Ok i got my red ball but when i click jump nothing happens is there something wrong?
1st Jan 2022, 9:09 PM
MrTobeDaBull
MrTobeDaBull - avatar
+ 2
You need to re-draw the circle... Is it from the Game Development course? It is a pro project and I cannot access it but I assume they give an example for how to make the ball jump
2nd Jan 2022, 1:01 PM
Lisa
Lisa - avatar
+ 2
I think the gist is this: When you click the button * update count * update circle position * clear canvas * draw circle on canvas (with new position)
2nd Jan 2022, 1:16 PM
Lisa
Lisa - avatar
+ 1
Put all your code inside if window.onload, else it will try to get the canvas before the canvas tag is loaded (that's the error in line 14)
1st Jan 2022, 9:07 PM
Lisa
Lisa - avatar
+ 1
When we click the button, count is increased by 1. What do you should happen?
1st Jan 2022, 9:15 PM
Lisa
Lisa - avatar
+ 1
You never display or output it. You could put a console.log(count); in the onclick function
1st Jan 2022, 9:29 PM
Lisa
Lisa - avatar
+ 1
Yes, after increasing count
1st Jan 2022, 9:32 PM
Lisa
Lisa - avatar
+ 1
I mean: btn.onclick = function() { count += 1; console.log(count); } Whenever you ick the button, count will be shown
1st Jan 2022, 9:48 PM
Lisa
Lisa - avatar
+ 1
The button function is already connected to the button element – you do this with the onclick in your js
2nd Jan 2022, 12:54 PM
Lisa
Lisa - avatar
+ 1
And redraw a circle?
2nd Jan 2022, 1:02 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Yes, its suppose to increase by 1 but i dont see it
1st Jan 2022, 9:26 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Where it says btn.onclick or where exactly?
1st Jan 2022, 9:31 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Tbh i have no idea can you like show me
1st Jan 2022, 9:41 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
You have to connect the jump button in HTML to js
2nd Jan 2022, 7:05 AM
Sxhil
Sxhil - avatar
0
How do you do that?
2nd Jan 2022, 12:52 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Ok now whenever i press the button the cirxle dissapears and it doesnt jump i think i did it right?
2nd Jan 2022, 12:58 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Yes its the Game Development with JS
2nd Jan 2022, 1:02 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
Make use of requestAnimationFrame or setInterval
2nd Jan 2022, 3:00 PM
Jamari McFarlane
Jamari McFarlane - avatar
0
Can you show a example?
2nd Jan 2022, 7:26 PM
MrTobeDaBull
MrTobeDaBull - avatar
0
See how everything dissapears
2nd Jan 2022, 7:29 PM
MrTobeDaBull
MrTobeDaBull - avatar