Game Development Reference
In-Depth Information
There will now be an image of some coins and another image of a huge bunny head,
which are both drawn on top of the background layer. The positions of each actor are
explicitly set to certain coordinates by calling setPosition() on each actor.
Adding the logos layer
Make the following changes in MenuScreen to add the logos layer:
private Table buildLogosLayer () {
Table layer = new Table();
layer.left().top();
// + Game Logo
imgLogo = new Image(skinCanyonBunny, "logo");
layer.add(imgLogo);
layer.row().expandY();
// + Info Logos
imgInfo = new Image(skinCanyonBunny, "info");
layer.add(imgInfo).bottom();
if (debugEnabled) layer.debug();
return layer;
}
The logos layer is anchored in the top-left corner of the screen. After this, an image
logo is added to the table followed by a call of the row() and expandY() methods.
Every time you call add() on a Table widget, TableLayout will add a new column,
which means the widget grows in a horizontal direction. So, if you want to start a
new row, you can tell TableLayout about this by calling row() . The expandY()
method expands the empty space in a vertical direction. The expansion is done by
shifting the widgets to the bounds of the cell.
After this, more image information is added to the table, which is literally pushed
down to the bottom edge due to the call of expandY() .
Lastly, there is a call to layer.debug() , which is the way to tell TableLayout the
object it should draw debug visuals for.
Adding the controls layer
Make the following changes in MenuScreen to add the controls layer:
private Table buildControlsLayer () {
Table layer = new Table();
layer.right().bottom();
 
Search WWH ::




Custom Search