Game Development Reference
In-Depth Information
This hint might sound trivial, but this is such a big time saver that it is
definitely worth pointing it out.
The code you just added to MenuScreen contains some additional
debug code that will call rebuildStage() in periodic intervals defined
in seconds by DEBUG_REBUILD_INTERVAL . You can enable periodic
refreshing by simply setting debugEnabled to true . This will give
you live updates at runtime, assuming that you are running the game
in debug mode on the desktop, and will allow you to take advantage of
JVM's awesome Code Hot Swapping feature.
Adding the background layer
Make the following changes in MenuScreen to add the background layer:
private Table buildBackgroundLayer () {
Table layer = new Table();
// + Background
imgBackground = new Image(skinCanyonBunny, "background");
layer.add(imgBackground);
return layer;
}
There will now be a background image drawn to the scene of the menu screen. The
image is referenced using the background name that we defined earlier in our skin
file ( canyonbunny-ui.json ). If you change the size of the screen, the stage will
adjust accordingly along with the background layer and its Image widget.
Adding the objects layer
Make the following changes in MenuScreen to add the objects layer:
private Table buildObjectsLayer () {
Table layer = new Table();
// + Coins
imgCoins = new Image(skinCanyonBunny, "coins");
layer.addActor(imgCoins);
imgCoins.setPosition(135, 80);
// + Bunny
imgBunny = new Image(skinCanyonBunny, "bunny");
layer.addActor(imgBunny);
imgBunny.setPosition(355, 40);
return layer;
}
 
Search WWH ::




Custom Search