Libgdx getProperties().get("value") 给我奇怪的回应

Libgdx getProperties().get("value") give me strange response

我对 getProperties().get("value") 的反应很奇怪。

您可以在下面看到我的 tmx file 和我的程序提供的值。

 <objectgroup name="objects">   <object id="1" name="player" type="player" x="256" y="3072" width="1290" height="1290">    <properties>
    <property name="name" value="Ahhhh"/>
    <property name="nom" value="Bhhhh"/>
    <property name="velocity" value="1.0"/>    </properties>   </object>  </objectgroup>

源代码

    MapObject mapPlayer = currentMap.getLayers().get("objects").getObjects().get("player");
MapObjects mapObject = currentMap.getLayers().get("objects").getObjects();
for (Iterator<String> iter = mapPlayer.getProperties().getKeys(); iter.hasNext(); )
{
    System.out.println("#############"+iter.next());
}
System.out.println("**************** player name :  " + mapPlayer.getProperties().get("name", String.class));
RectangleMapObject rect = (RectangleMapObject) mapObject.get("player");
float x = (float) rect.getRectangle().x;
float y = (float) rect.getRectangle().y;
float width = rect.getRectangle().width;
float height = rect.getRectangle().height;

System.out.println("**************** player coordinates X :  " +x);
System.out.println("**************** player coordinates Y:  "+y);
System.out.println("**************** player coordinates width :  " +width);
System.out.println("**************** player coordinates height:  "+height);
System.out.println("**************** player coordinates X :  " +mapPlayer.getProperties().get("x", Integer.class));
System.out.println("**************** player coordinates Y:  "+mapPlayer.getProperties().get("y", Integer.class));
System.out.println("**************** player velocity :  "+mapPlayer.getProperties().get("velocity", Integer.class));
#######width #######name #######nom #######id #######velocity #######height #######x #######y #######type

**************** player name : Ahhhh **************** player coordinates X : 256.0 **************** player coordinates Y: 3318.0 **************** player coordinates width : 1290.0 **************** player coordinates height: 1290.0 **************** player coordinates X : 256.0 **************** player coordinates Y: 3318.0 **************** player velocity : 1.0

为什么 Y 没有显示正确的值?

谢谢

这可能是因为 libgdx 的 Y 轴方向相反(指向上方而不是像 Tiled 中那样向下)并且试图通过自动将 Y 坐标转换成它自己的坐标来提供帮助 space加载地图时。