mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 00:31:29 +08:00
fix(map) 修复瓦片显示偏移问题
This commit is contained in:
1 parent
66544082b2
commit
200eb886dd
2 files changed
+333
-15
No files matched your search
@@ -476,6 +476,9 @@ export default class MapEditTestScene extends Phaser.Scene {
|
||||
|
||||
// 先设置裁剪区域,使用图块在大图中的精确位置作为起始点
|
||||
tile.setCrop(frameX, frameY, cropWidth, cropHeight);
|
||||
|
||||
// 调整瓦片位置,使其相对于容器(0,0)位置显示,而不是原图像位置
|
||||
tile.setPosition(-frameX*2, -frameY*2);
|
||||
|
||||
// 然后设置缩放,放大显示
|
||||
tile.setScale(2);
|
||||
@@ -739,6 +742,9 @@ export default class MapEditTestScene extends Phaser.Scene {
|
||||
// 先设置裁剪区域,使用图块在大图中的精确位置
|
||||
tile.setCrop(cropX, cropY, cropWidth, cropHeight);
|
||||
|
||||
// 调整瓦片位置,使其相对于目标位置(0,0)显示,而不是原图像位置
|
||||
tile.setPosition(drawX - cropX*2, drawY - cropY*2);
|
||||
|
||||
// 然后设置缩放,确保瓦片填满地图网格
|
||||
const scaleFactor = mapTileSize / cropWidth;
|
||||
tile.setScale(scaleFactor);
|
||||
|
||||
Reference in new issue
Block a user