简体   繁体   English

平铺的地图对象坐标

[英]tiled map object coordinates

I have a problem with tiled map object: 我对平铺的地图对象有疑问:

I created a rectangle object by tiled map editor. 我通过平铺的地图编辑器创建了一个矩形对象。 When I render the map in Libgdx I want to create a text(using font) on this rectangle. 当我在Libgdx中渲染地图时,我想在此矩形上创建文本(使用字体)。 For this reason I get the rectangle's coordinates x,y and create the text in this position. 因此,我得到矩形的坐标x,y并在此位置创建文本。 My problem is that the text doesn't visualize in the position that I see in the tiled map editor and if I move the rectangle in other position it doesn't render on the screen. 我的问题是文本无法在平铺的地图编辑器中看到的位置显示,并且如果我将矩形移到其他位置,则无法在屏幕上呈现。

How Do I solve this problem? 我该如何解决这个问题?

My code: 我的代码:

String textToSet=(String)properties.get("rectangle");
float x=(float) properties.get("x");
float y= (float) properties.get("y");

batch.begin();
font.draw(batch,textToSet,x,y);
batch.end();

What do you mean by "position that I see in the tiled map editor"? “我在平铺的地图编辑器中看到的位置”是什么意思? Do you mean tiles? 你是说瓷砖吗? You may have to convert your coordinates. 您可能需要转换坐标。

ie

x/tilesize y/tilesize x /平铺y /平铺

If you are looking at its position in pixels in tiled map editor then i don't know. 如果您在平铺的地图编辑器中以像素为单位查看其位置,那么我不知道。 But see if this is the problem you were having. 但是,看看这是否是您遇到的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM