本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.ui.Table.setPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java Table.setPosition方法的具體用法?Java Table.setPosition怎麽用?Java Table.setPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.scenes.scene2d.ui.Table
的用法示例。
在下文中一共展示了Table.setPosition方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MessageWindow
import com.badlogic.gdx.scenes.scene2d.ui.Table; //導入方法依賴的package包/類
public MessageWindow(String message, BitmapFont font, float width, float height) {
setTouchable(Touchable.enabled);
setBounds(width / 2 - width / 4, height / 2 - height / 10, width / 2, height / 5);
texture = new Texture("theme/basic/ui/Window.png");
this.message = message;
table = new Table();
table.setSize(getWidth(), getHeight());
table.align(Align.center | Align.top);
table.setPosition(getX(), getY());
Label label = new Label(message, new Label.LabelStyle(font, Color.BLACK));
label.setWrap(true);
label.setFontScale(0.7f);
Label label2 = new Label("Tap to continue", new Label.LabelStyle(font, Color.BLACK));
label2.setFontScale(0.6f);
table.add(label).width(getWidth());
table.row();
table.add(label2).width(getWidth()).expandY();
table.pad(0, 30, 0, 30);
}
示例2: centerPosition
import com.badlogic.gdx.scenes.scene2d.ui.Table; //導入方法依賴的package包/類
public static void centerPosition(Table dialog)
{
dialog.setPosition(Math.round((Gdx.graphics.getWidth() - dialog.getWidth()) / 2),
Math.round((Gdx.graphics.getHeight() - dialog.getHeight()) / 2));
}
示例3: 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);
}
示例4: 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);
}