回答編集履歴
1
a
answer
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
fitsize();
|
20
20
|
|
21
21
|
let x = 0, y = 0, radius = 50, vx = 2, vy = 2, cnt = 0;
|
22
|
-
let timer = setInterval(
|
22
|
+
let timer = setInterval(() => {
|
23
23
|
++cnt;
|
24
24
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
25
25
|
ctx.beginPath();
|
@@ -59,7 +59,7 @@
|
|
59
59
|
fitsize();
|
60
60
|
|
61
61
|
let x = 0, y = 0, radius = 50, vx = 2, vy = 2, cnt = 0;
|
62
|
-
let timer = setInterval(
|
62
|
+
let timer = setInterval(() => {
|
63
63
|
++cnt;
|
64
64
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
65
65
|
ctx.beginPath();
|
@@ -102,8 +102,8 @@
|
|
102
102
|
fitsize();
|
103
103
|
|
104
104
|
let x = 0, y = 0, radius = 50, vx = 2, vy = 2;
|
105
|
-
requestAnimationFrame(function
|
105
|
+
requestAnimationFrame(function draw() {
|
106
|
-
requestAnimationFrame(
|
106
|
+
requestAnimationFrame(draw);
|
107
107
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
108
108
|
ctx.beginPath();
|
109
109
|
if (x + 2 * radius > canvas.width || x < 0) vx = -vx;
|