Game Development Reference
In-Depth Information
Next, we will create a suitable JSON file to define the skin of our menu widgets.
Create a new file in
CanyonBunny-android/assets/images/
called
canyonbunny-
ui.json
and add the following lines:
{
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
play: { down: play-dn, up: play-up },
options: { down: options-dn, up: options-up }
},
com.badlogic.gdx.scenes.scene2d.ui.Image: {
background: { drawable: background },
logo: { drawable: logo },
info: { drawable: info },
coins: { drawable: coins },
bunny: { drawable: bunny },
},
}
On running the
CanyonBunny-html
project, it will show a
json
parsing error while parsing the
CanyonBunny-ui.json
file. This
is because of GWT reflection. GWT does not provide reflection in the
same way as Java. Hence, extra steps are required to make reflection
available in the GWT project.
Open the
GwtDefinition.gwt.xml
file in your
CanyonBunny-html
project and update it with the following code:
<module>
...
<extend-configuration-property
name="gdx.reflect.include"
value="com.badlogic.gdx.scenes.scene2d.ui"
/>
<extend-configuration-property
name="gdx.reflect.include"
value="com.badlogic.gdx.utils" />
</module>
The preceding code will enable the
gwt
reflection for the packages
com.badlogic.gdx.scenes.scene2d.ui
and
com.badlogic.
gdx.utils
, which is required to parse Scene2D UI elements. Make
sure that you add
extend-configuration-property
below
set-configuration-property
. To find out more about LibGDX
reflection, visit
https://github.com/libgdx/libgdx/wiki/