我正在使用 AngularJS 编写游戏,但我遇到了图 block 大小配置问题。
这是我的应用程序的屏幕:
如您所见,左侧的图 block 被边框分割,而不是右侧的图 block 。 在不同的屏幕尺寸下,它更加明显。
我的 map 基于窗口大小和图 block 。
// Canvas size
canvas.width = window.innerWidth;
canvas.height = window.innerHeight-90; // minus menu size
// Camera size
function Camera(map, width, height) {
this.x = 0;
this.y = 0;
this.width = width;
this.height = height;
this.maxX = map.cols * map.tsize - width;
this.maxY = map.rows * map.tsize - height;
}
// Tile size
tsize: window.innerWidth/20
代码基于MDN教程: Link to the Game Development tutorial
最佳答案
这可能只是由于渲染图 block 时的舍入问题造成的。这可能是由于相机位置不均匀或变焦造成的。
尝试对图 block 大小使用ceil()
,或者只是使其稍大一些。
关于javascript - HTML Canvas 与 javascript 之间的差距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61431271/