【发布时间】:2020-07-24 08:03:52
【问题描述】:
我正在查看 W3 在画布上的 ref,在一个示例中,他们创建了一个红色块并通过以下计算确定其 x,y:
this.angle += this.moveAngle * Math.PI / 180;
this.x += this.speed * Math.sin(this.angle);
this.y -= this.speed * Math.cos(this.angle);
sin 和 cos 在改变方块的 x,y 位置时起什么作用?
【问题讨论】:
标签: javascript math html5-canvas trigonometry