【发布时间】:2018-03-15 18:57:01
【问题描述】:
我正在开发一个打字稿网页游戏。
所以基本上,物体从coorY开始,速度为dy,其当前坐标为Y。
当前Y小于coorY(10)时向右移动,大于coorY + 50 (60),它向左移动。
public Move(): void {
this._dy = 1;
this.dir = true;
if (this.y > this.coorY + 50) {
this.dir = true;
console.log("Forth " + (this.y - this.coorY));
}
else if (this.y < this.coorY) {
this.dir = false;
console.log("Back " + (this.y - this.coorY));
}
if (this.dir) {
this.y -= this._dy;
}
else if (!this.dir) {
this.y += this._dy;
}
}
但不知何故,物体移动得很少,看起来像是在晃动,或者只是停留在原来的位置。如何让它来回移动?
【问题讨论】:
标签: typescript object position