我正在尝试渲染等距平铺地图,例如,如果我使用OrthogonalTiledMapRenderer
进行正交平铺地图box2dObjects/bodies
在完成MapObjects
初始化的代码后呈现完美:
if (object instanceof RectangleMapObject) {
RectangleMapObject rectangleObj = (RectangleMapObject)object;
Rectangle rectangle = rectangleObj.getRectangle();
position= new Vector2((rectangle.x+rectangle.getWidth()*0.5f)/Game.SCALE_PIXELS_ToMETERS, (rectangle.y+rectangle.getHeight()*0.5f)/Game.SCALE_PIXELS_ToMETERS);
size= new Vector2(rectangle.getWidth()/Game.SCALE_PIXELS_ToMETERS, rectangle.getHeight()/Game.SCALE_PIXELS_ToMETERS);
PolygonShape polygon = new PolygonShape();
polygon.setAsBox(rectangle.width * 0.5f / Game.SCALE_PIXELS_ToMETERS,rectangle.height * 0.5f / Game.SCALE_PIXELS_ToMETERS);
shape=polygon;
}
else if (object instanceof PolygonMapObject) {
PolygonMapObject polygonObj = (PolygonMapObject)object;
PolygonShape polygon = new PolygonShape();
float[] vertices = polygonObj.getPolygon().getTransformedVertices();
float[] worldVertices = new float[vertices.length];
for (int i = 0; i < vertices.length; ++i) {
worldVertices[i] = vertices[i] / Game.SCALE_PIXELS_ToMETERS;
}
polygon.set(worldVertices);
shape=polygon;
position=null;
}
else if (object instanceof PolylineMapObject) {
PolylineMapObject polyLineObj = (PolylineMapObject)object;
Polyline polyLine=polyLineObj.getPolyline();
position= new Vector2(polyLineObj.getPolyline().getX(),polyLineObj.getPolyline().getY());
//vector=scaleToMeters(vector,polyLine.getLength(),polyLineObj.height);
shape = getPolyline((PolylineMapObject)object);
}
else if (object instanceof CircleMapObject) {
CircleMapObject circleObj = (CircleMapObject)object;
Circle circle = circleObj.getCircle();
CircleShape circleShape = new CircleShape();
circleShape.setRadius(circle.radius / Game.SCALE_PIXELS_ToMETERS);
circleShape.setPosition(new Vector2(circle.x / Game.SCALE_PIXELS_ToMETERS, circle.y / Game.SCALE_PIXELS_ToMETERS));
position= new Vector2(circle.x,circle.y);
shape = circleShape;
}
Entity entity=null;
if(object.getName().equals("StaticWall")) entity=createStaticWallObject(shape,object.getName(),object,position);
if(entity!=null) dynamicEntitys.add(entity);
一切运作完美 - &gt;&gt;
但如果我尝试使用IsometricTiledMapRenderer
并使用debug mode:on
运行它,我会遇到以下问题:
但我不希望mapobjects成为Orthogonal!