-1
これは私のコードです。私はなぜ円が動いていないのか分かりません。それはちょうど私がxとyの座標をどこに記述したかのままです。canvas htmlでサークルを移動できませんか?
class Circle {
constructor(x, y, r, clr) {
this.radius = r;
this.x = x;
this.y = y;
this.clr = clr;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, 2*Math.PI);
ctx.fillStyle = this.clr;
ctx.fill();
ctx.closePath();
}
move(finalx, finaly) {
this.finalx = finalx;
this.finaly = finaly;
while (this.finalx != this.x && this.finaly != this.y) {
this.x += 2;
this.y += 2;
}
}
}
var x = new Circle(150, 225, 50, black);
x.move(400, 25);
HTML5キャンバスはFlashのようには機能しません。 Canvasのアニメーションでは、すべてのフレームでCanvasを描画してクリアする必要があります。それについてはWeb上のチュートリアルをチェックしてください。 [例](https://www.kirupa.com/html5/creating_simple_html5_canvas_animation.htm) – michaPau