本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Table.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Table.setWidth方法的具体用法?Java Table.setWidth怎么用?Java Table.setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.Table
的用法示例。
在下文中一共展示了Table.setWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MidSection
import com.badlogic.gdx.scenes.scene2d.ui.Table; //导入方法依赖的package包/类
public MidSection(Skin skin) {
this.setSkin(skin);
Table waveInfoContainer = new Table(skin);
Table waveTable = new StatPanel(skin);
Table nextEnemyTable = new StatPanel(skin);
Table nextWaveTable = new StatPanel(skin);
Table buttonContainer = new Table(skin);
// labels
Label waveText = new Label("Wave:", skin , "fontHemi20" , "white");
Label nextEnemyText = new Label("Next Enemy", skin, "fontHemi20", "white");
_currentWave = new Label("0",skin , "fontHemi20" , "white");
Label maxWaves = new Label(" / " + PlayState.MAX_WAVES , skin , "fontHemi20" , "white");
_next_enemy_value = new Label("",skin , "fontHemi20","white");
Label nextWaveTimeText = new Label("In:", skin, "fontHemi20", "white");
_next_wave_time_value = new Label("",skin , "fontHemi20","white");
// buttons
_nextWaveBtn = new TextButton("START",skin);
// tables
waveTable.add(_currentWave);
waveTable.add(maxWaves);
waveInfoContainer.add(waveText).expand().align(Align.left).row();
waveInfoContainer.add(waveTable).colspan(2).expand().fill().row();
waveInfoContainer.add(nextEnemyText).align(Align.bottomLeft);
waveInfoContainer.add(nextWaveTimeText).align(Align.bottomLeft).row();
nextEnemyTable.add(_next_enemy_value).align(Align.center);
nextWaveTable.add(_next_wave_time_value).align(Align.bottom).expand().prefWidth(62).align(Align.center);
waveInfoContainer.add(nextEnemyTable).align(Align.bottomLeft).expand().spaceRight(3f);
waveInfoContainer.add(nextWaveTable).align(Align.bottomRight).expand().spaceLeft(3f);
waveInfoContainer.setWidth(150);
this.add(waveInfoContainer).expand().align(Align.bottom).row();
buttonContainer.add(_nextWaveBtn).expand().fill().spaceTop(0);
this.add(buttonContainer).expand().fillX().spaceTop(5).align(Align.bottom).padBottom(2);
}
示例2: initGuiInGame
import com.badlogic.gdx.scenes.scene2d.ui.Table; //导入方法依赖的package包/类
private void initGuiInGame() {
mGuiStage = new Stage(new ScreenViewport());
Table gameScore = new Table();
if (DEBUG_RENDERER) {
gameScore.debug();
}
float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen
float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen
gameScore.setWidth(scorePanelWidth);
gameScore.setHeight(scorePanelHeight);
gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f));
gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f);
gameScore.setBackground(new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24)));
gameScore.pad(32.f);
Label scoreLabel = new Label("Score", new Label.LabelStyle(
mDefaultFont, COLOR_FONT));
scoreLabel.setFontScale(1.2f);
gameScore.add(scoreLabel).expand();
gameScore.row();
mScoreLabel = new Label("" + mPointTotal, new Label.LabelStyle(
mDefaultFont, COLOR_FONT));
mScoreLabel.setFontScale(2.0f);
gameScore.add(mScoreLabel).expand();
mGuiStage.addActor(gameScore);
}
示例3: create
import com.badlogic.gdx.scenes.scene2d.ui.Table; //导入方法依赖的package包/类
public void create() {
Stage stage = new Stage(new ScreenViewport());
getComponentByType(GuiComponent.class).stage = stage;
Table gameScore = new Table();
float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen
float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen
gameScore.setWidth(scorePanelWidth);
gameScore.setHeight(scorePanelHeight);
gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f));
gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f);
gameScore.setBackground(new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24)));
gameScore.pad(32.f);
Label scoreLabel = new Label("Score", new Label.LabelStyle(
mFont, COLOR_FONT));
scoreLabel.setFontScale(1.2f);
gameScore.add(scoreLabel).expand();
gameScore.row();
mScoreLabel = new Label("" + 0, new Label.LabelStyle(mFont, COLOR_FONT));
mScoreLabel.setFontScale(2.0f);
gameScore.add(mScoreLabel).expand();
stage.addActor(gameScore);
}
示例4: initGuiGameOver
import com.badlogic.gdx.scenes.scene2d.ui.Table; //导入方法依赖的package包/类
private void initGuiGameOver() {
mGuiGameOverStage = new Stage(new ScreenViewport());
Table rootTable = new Table();
if (DEBUG_RENDERER) {
rootTable.debug();
}
// add margin on the bottom for iOS
final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0;
final float dialogMargin = 50.f;
final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f);
final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset;
rootTable.setWidth(dialogWidth);
rootTable.setHeight(dialogHeight);
rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset);
rootTable.background(
new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24)));
Label label = new Label("GAME OVER", mSkin);
label.setFontScale(2.f);
label.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
rootTable.add(label).expand().padTop(dialogHeight * 0.025f);
rootTable.row();
TextButton restartButton = new TextButton("RESTART", mSkin);
restartButton.getLabel().setFontScale(1.f);
restartButton.getLabel().setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
restartButton.addCaptureListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
onStartGame();
}
});
Array<Integer> highScores = fetchHighScores();
mHighScoreLabel = new Array<Label>();
for (int i = 0; i < highScores.size; i++) {
Label scoreLabel = new Label("high score: " + highScores.get(i), mSkin);
scoreLabel.setFontScale(1.0f);
scoreLabel.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
rootTable.add(scoreLabel).expand();
rootTable.row();
mHighScoreLabel.add(scoreLabel);
}
// don't like the scene2d interface, if has bad defaults and documentation
// try to correctly position the bottom restart button
rootTable.add(restartButton).expand().width(
dialogWidth - (dialogMargin * 4.f)).height(dialogHeight * 0.1f).bottom().padBottom(dialogHeight * 0.05f);
mGuiGameOverStage.addActor(rootTable);
}
示例5: create
import com.badlogic.gdx.scenes.scene2d.ui.Table; //导入方法依赖的package包/类
@Override
public void create() {
Stage stage = new Stage(new ScreenViewport());
getComponentByType(GuiComponent.class).stage = stage;
Table rootTable = new Table();
// add margin on the bottom for iOS
final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0;
final float dialogMargin = 50.f;
final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f);
final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset;
mDefaultMargin = dialogWidth * 0.03f;
rootTable.setWidth(dialogWidth);
rootTable.setHeight(dialogHeight);
rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset);
rootTable.background(
new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24)));
// HEADER
Label label = new Label("LEADERBOARD", mSkin);
label.setFontScale(1.6f);
label.setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
rootTable.add(label)
.expand(true, false)
.padTop(dialogHeight * 0.05f)
.padBottom(mDefaultMargin * 0.5f);
rootTable.row();
mScrollPaneTable = new Table(mSkin);
ScrollPane scrollPane = new ScrollPane(mScrollPaneTable);
rootTable.add(scrollPane)
.fill()
.expand()
.padTop(mDefaultMargin * 0.5f)
.padBottom(mDefaultMargin * 0.5f);
rootTable.row();
// RESTART button
TextButton restartButton = new TextButton("RESTART", mSkin);
restartButton.getLabel().setFontScale(1.f);
restartButton.getLabel().setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
restartButton.addCaptureListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
mEngine.getFirstEntityOfType(GameStateEntity.class).onStartGame();
}
});
// try to correctly position the bottom restart button
rootTable.add(restartButton)
.expand(true, false)
.width(dialogWidth - (dialogMargin * 4.f))
.height(dialogHeight * 0.08f)
.padTop(mDefaultMargin * 0.5f)
.padBottom(mDefaultMargin)
.padLeft(mDefaultMargin)
.padRight(mDefaultMargin)
.center();
stage.addActor(rootTable);
}