好的,所以我在libgdx(Android Studio)中做了一个简单的游戏。它既可以在台式机上也可以在Android上使用,但是在html中会引发以下错误:
未捕获的错误:java.lang.RuntimeException:java.lang.RuntimeException:找不到类'com.badlogic.gdx.maps.objects.RectangleMapObject'的类型
在我的代码中唯一使用RectangleMapObject
的代码是这样的:
for(MapObject mapObject: tiledMap.getLayers().get(1).getObjects().getByType(RectangleMapObject.class)){
Rectangle rectangle = ((RectangleMapObject)mapObject).getRectangle();
createGround(rectangle.getX()/ 70f, rectangle.getY() / 70f, rectangle.getWidth() / 70f, rectangle.getHeight()/70f);
}
我花了将近两天的时间试图使其正常工作,但一无所获。如果有人知道该问题的解决方案,其原因或类似的事情,我会真的寻求一些帮助:)
最佳答案
对gwt的反思需要一些按摩才能起作用
https://github.com/libgdx/libgdx/wiki/Reflection#gwt
将此添加到您的GdxDefinition.gwt.xml
:
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.objects.RectangleMapObject" />