Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Table#top()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table#top() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusBar.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public StatusBar(final Batch batch, final AssetManager assets) {
	overlay = new Stage(new ScreenViewport(), batch);

	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = assets.get(Assets.HUD_FONT);
	style.font.setFixedWidthGlyphs(NUMBER_GLYPHS);

	collectiblesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	livesLabel = new Label(String.format(TWO_DIGITS, 0), style);
	scoreLabel = new Label(String.format(EIGHT_DIGITS, 0), style);
	timeLabel = new Label(String.format(THREE_DIGITS, 0), style);

	TextureAtlas hudAtlas = assets.get(Assets.NINJA_RABBIT_ATLAS);

	Table table = new Table();
	table.add(new Image(hudAtlas.findRegion(SMALL_CARROT_REGION))).padRight(8.0f);
	table.add(collectiblesLabel).bottom();
	table.add(new Image(hudAtlas.findRegion(LIVES_REGION))).padLeft(15.0f);
	table.add(livesLabel).bottom();
	table.add(scoreLabel).expandX();
	table.add(new Image(hudAtlas.findRegion(TIME_REGION))).padRight(12.0f);
	table.add(timeLabel);
	table.setFillParent(true);
	table.top();
	table.pad(15.0f);

	overlay.addActor(table);
}
 
Example 2
Source File: LevelStartScreen.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public LevelStartScreen(final NinjaRabbitGame game) {
	super(game);
	PlayerStatus playerStatus = game.getPlayerStatus();
	stage = new Stage(new ScreenViewport(), game.getBatch());

	Label.LabelStyle style = new Label.LabelStyle();
	style.fontColor = Color.WHITE;
	style.font = game.getAssetsManager().get(Assets.HUD_FONT);

	TextureAtlas hudAtlas = game.getAssetsManager().get(Assets.NINJA_RABBIT_ATLAS);

	Label collectiblesLabel = new Label(String.format(TWO_DIGITS, playerStatus.getCollectibles()), style);
	Label livesLabel = new Label(String.format(LIVES_FORMAT, playerStatus.getLives()), style);
	Label scoreLabel = new Label(String.format(EIGHT_DIGITS, playerStatus.getScore()), style);
	Label timeLabel = new Label(String.format(THREE_DIGITS, playerStatus.getTime()), style);

	Table status = new Table();
	status.add(new Image(hudAtlas.findRegion(SMALL_CARROT_REGION))).padRight(4.0f);
	status.add(collectiblesLabel).bottom();
	status.add(scoreLabel).expandX();
	status.add(new Image(hudAtlas.findRegion(TIME_REGION))).padRight(12.0f);
	status.add(timeLabel).row();
	status.setFillParent(true);
	status.top();
	status.pad(15.0f);
	stage.addActor(status);

	Table levelInfo = new Table();
	levelInfo.add(new Label(LEVEL_LABEL, style)).expandX().right().padRight(18.0f);
	levelInfo.add(new Label(String.format(LEVEL_FORMAT, playerStatus.getWorld(), playerStatus.getLevel()), style)).expandX()
			.left().padTop(18.0f).row();
	Image livesIcon = new Image(hudAtlas.findRegion(LIVES_REGION));
	levelInfo.add(livesIcon).expandX().right().spaceRight(25f);
	levelInfo.add(livesLabel).expandX().left().bottom();
	levelInfo.setFillParent(true);
	stage.addActor(levelInfo);

}