#28 新增tiledMapRenderer用于渲染tiledmap

This commit is contained in:
yhh
2020-08-12 18:08:12 +08:00
parent 167ef03df6
commit e5805960e0
14 changed files with 1402 additions and 2 deletions
+32
View File
@@ -67,6 +67,38 @@ module es {
console.error(`tile gid${gid}未在任何tileset中找到`);
}
/**
* 转换从世界平铺位置获取tilemap边界
* @param x
* @param clampToTilemapBounds
*/
public worldToTilePositionX(x: number, clampToTilemapBounds = true){
let tileX = Math.floor(x / this.tileWidth);
if (!clampToTilemapBounds)
return tileX;
return MathHelper.clamp(tileX, 0, this.width - 1);
}
/**
* 转换从世界平铺位置获取tilemap边界
* @param y
* @param clampToTilemapBounds
*/
public worldToTilePositionY(y: number, clampToTilemapBounds = true){
let tileY = Math.floor(y / this.tileHeight);
if (!clampToTilemapBounds)
return tileY;
return MathHelper.clamp(tileY, 0, this.height - 1);
}
/**
* 按名称获取平铺层
* @param name
*/
public getLayer(name: string): ITmxLayer {
return this.layers.get(name);
}
/**
* 更新他们的动画tile
*/