Game Development Reference
In-Depth Information
This method builds a table containing the audio settings. First, a label showing the
text Audio in an orange color is added. Then, a checkbox (another label showing the
text Sound ) and a slider are added in the next row for the sound settings. This is also
done for the music settings in the same way.
Next, add the buildOptWinSkinSelection() method to the same class:
private Table buildOptWinSkinSelection () {
Table tbl = new Table();
// + Title: "Character Skin"
tbl.pad(10, 10, 0, 10);
tbl.add(new Label("Character Skin", skinLibgdx,
"default-font", Color.ORANGE)).colspan(2);
tbl.row();
// + Drop down box filled with skin items
selCharSkin = new SelectBox<CharacterSkin>(skinLibgdx);
selCharSkin.setItems(CharacterSkin.values());
selCharSkin.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
onCharSkinSelected(((SelectBox<CharacterSkin>)
actor).getSelectedIndex());
}
});
tbl.add(selCharSkin).width(120).padRight(20);
// + Skin preview image
imgCharSkin = new Image(Assets.instance.bunny.head);
tbl.add(imgCharSkin).width(50).height(50);
return tbl;
}
This method builds a table that contains the character skin selection via a drop-down
box and a preview image next to it. A ChangeListener method is added to the drop-
down widget selCharSkin so that the setting and preview image is updated by
calling onCharSkinSelected() whenever a new selection occurs.
 
Search WWH ::




Custom Search