修复tiledmap tmxDirectory不正确问题
This commit is contained in:
@@ -120,8 +120,14 @@ module es {
|
||||
if (poly.points.length >= 2){
|
||||
this.polygonShape.graphics.beginFill(Colors.colliderEdge, 0);
|
||||
this.polygonShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderEdge);
|
||||
for (let i = 1; i < poly.points.length; i ++)
|
||||
this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x, poly.position.y + poly.points[i].y);
|
||||
for (let i = 1; i < poly.points.length; i ++){
|
||||
if (i == 1){
|
||||
this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x, poly.position.y + poly.points[i].y);
|
||||
}else{
|
||||
this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x, poly.position.y + poly.points[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
this.polygonShape.graphics.lineTo(poly.position.x + poly.points[poly.points.length - 1].x, poly.position.y + poly.points[0].y);
|
||||
this.polygonShape.graphics.endFill();
|
||||
}
|
||||
@@ -129,13 +135,13 @@ module es {
|
||||
this.pixelShape1.graphics.clear();
|
||||
this.pixelShape1.graphics.beginFill(Colors.colliderPosition, 0);
|
||||
this.pixelShape1.graphics.lineStyle(4 * Size.lineSizeMultiplier, Colors.colliderPosition);
|
||||
this.pixelShape1.graphics.lineTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.moveTo(this.entity.transform.position.x, this.entity.transform.position.y);
|
||||
this.pixelShape1.graphics.endFill();
|
||||
|
||||
this.pixelShape2.graphics.clear();
|
||||
this.pixelShape2.graphics.beginFill(Colors.colliderCenter, 0);
|
||||
this.pixelShape2.graphics.lineStyle(2 * Size.lineSizeMultiplier, Colors.colliderCenter);
|
||||
this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x,
|
||||
this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x,
|
||||
this.entity.transform.position.y + this.shape.center.y);
|
||||
this.pixelShape2.graphics.endFill();
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ module es {
|
||||
if (!camera)
|
||||
return false;
|
||||
|
||||
this.isVisible = camera.bounds.intersects(this.displayObject.getBounds().union(this.bounds));
|
||||
this.isVisible = camera.bounds.intersects(this.bounds);
|
||||
return this.isVisible;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,10 +123,8 @@ module es {
|
||||
public render(camera: Camera) {
|
||||
this.sync(camera);
|
||||
|
||||
let afterPos = new Vector2(this.entity.position.x + this.localOffset.x - camera.position.x + camera.origin.x,
|
||||
this.entity.position.y + this.localOffset.y - camera.position.y + camera.origin.y);
|
||||
if (this.displayObject.x != afterPos.x) this.displayObject.x = afterPos.x;
|
||||
if (this.displayObject.y != afterPos.y) this.displayObject.y = afterPos.y;
|
||||
if (this.displayObject.x != this.bounds.x) this.displayObject.x = this.bounds.x;
|
||||
if (this.displayObject.y != this.bounds.y) this.displayObject.y = this.bounds.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ module es {
|
||||
export class TiledMapLoader {
|
||||
public static loadTmxMap(map: TmxMap, filePath: string) {
|
||||
let xMap = RES.getRes(filePath);
|
||||
return this.loadTmxMapData(map, xMap);
|
||||
return this.loadTmxMapData(map, xMap, RES.getResourceInfo(filePath));
|
||||
}
|
||||
|
||||
public static async loadTmxMapData(map: TmxMap, xMap: any) {
|
||||
public static async loadTmxMapData(map: TmxMap, xMap: any, info: any) {
|
||||
map.version = xMap["version"];
|
||||
map.tiledVersion = xMap["tiledversion"];
|
||||
map.width = xMap["width"];
|
||||
@@ -29,6 +29,7 @@ module es {
|
||||
// 我们保持记录的最大瓷砖大小的情况下,图像tileset随机大小
|
||||
map.maxTileWidth = map.tileWidth;
|
||||
map.maxTileHeight = map.tileHeight;
|
||||
map.tmxDirectory = info.root + info.url.replace(".", "_").replace(info.name, "");
|
||||
|
||||
map.tilesets = [];
|
||||
for (let e of xMap["tilesets"]) {
|
||||
|
||||
@@ -202,7 +202,11 @@ module es {
|
||||
obj.shape.graphics.clear();
|
||||
obj.shape.graphics.lineStyle(1, 0xa0a0a4);
|
||||
for (let i = 0; i < points.length; i ++){
|
||||
obj.shape.graphics.lineTo(points[i].x, points[i].y);
|
||||
if (i == 0){
|
||||
obj.shape.graphics.moveTo(points[i].x, points[i].y);
|
||||
}else{
|
||||
obj.shape.graphics.lineTo(points[i].x, points[i].y);
|
||||
}
|
||||
}
|
||||
obj.shape.graphics.endFill();
|
||||
debugRender(obj, pos);
|
||||
|
||||
Reference in New Issue
Block a user