问题
Ok, so I made a simple game in libgdx (Android Studio). It works on desktop as well as on Android but in html throws this error :
Uncaught Error: java.lang.RuntimeException: java.lang.RuntimeException: Couldn't find Type for class 'com.badlogic.gdx.maps.objects.RectangleMapObject'
The only code that uses RectangleMapObject
in my code is this:
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);
}
I spent almost two days trying to make it work and found nothing. If someone knows the solution to this problem, Its cause or anything like that i would realy appriciate some help :)
回答1:
Reflection on gwt requires some massaging to work
https://github.com/libgdx/libgdx/wiki/Reflection#gwt
Add this to your GdxDefinition.gwt.xml
:
<extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.objects.RectangleMapObject" />
来源:https://stackoverflow.com/questions/44719343/couldnt-find-type-for-class-com-badlogic-gdx-maps-objects-rectanglemapobject