本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.setAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setAlignment方法的具体用法?Java Label.setAlignment怎么用?Java Label.setAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.Label
的用法示例。
在下文中一共展示了Label.setAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: StageLoad
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
/**
* Loading stage
* @param doLoad should resources be loaded? It acts as a splash screen otherwise.
*/
public StageLoad(boolean doLoad) {
this.doLoad = doLoad;
// Create icon
icon = new Image(new Texture("image/icon-512.png"));
int size = Gdx.graphics.getHeight();
if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth())
size = Gdx.graphics.getWidth();
icon.setSize(size, size);
icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2,
Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2);
addActor(icon);
// Loading Text
Label.LabelStyle loadingStyle = new Label.LabelStyle();
loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720);
loading = new Label("DRC Sim", loadingStyle);
loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f);
loading.setAlignment(Align.center);
addActor(loading);
}
示例2: ServerSetupMenu
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public ServerSetupMenu(final Save save) {
super();
title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
saveLabel.setAlignment(Align.center);
port = new TextField("", skin);
port.setMessageText(Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
start = new TextButton(Localization.get("menu.server.start"), skin);
back = MenuTools.getBackButton(this);
start.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT) : Integer.parseInt(port.getText());
Adapter.setMenu(new ServerRunningMenu(save, p));
}
});
stage.addActor(title);
stage.addActor(saveLabel);
stage.addActor(port);
stage.addActor(start);
stage.addActor(back);
}
示例3: SingleplayerSaveDeleteMenu
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public SingleplayerSaveDeleteMenu(final Save save) {
title = new Label(Localization.get("menu.singleplayer.delete.title"), skin.get("title", Label.LabelStyle.class));
text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin);
delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin);
back = MenuTools.getBackButton(this);
text.setAlignment(Align.center);
delete.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
ClientSaveManager.deleteSave(save);
Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this);
if (!(prev instanceof SingleplayerSavesMenu)) return;
((SingleplayerSavesMenu) prev).updateSavesList();
Adapter.setMenu(prev);
}
});
stage.addActor(title);
stage.addActor(text);
stage.addActor(delete);
stage.addActor(back);
}
示例4: createComponents
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
private void createComponents()
{
btBackToMainMenu = new TextButton("Back to Main Menu", skin);
btBackToMainMenu.center();
btBackToMainMenu.setWidth(600);
btBackToMainMenu.setHeight(80);
btBackToMainMenu.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
AL.getGame().setScreen(AL.getScreenManager().get(MainMenuScreen.class));
}
});
btBackToMainMenu.setPosition(1920 / 2 - 300, 1080 / 2 + 40);
stage.addActor(btBackToMainMenu);
endgameLabel = new Label(endgameText, skin);
endgameLabel.setWidth(600);
endgameLabel.setHeight(80);
endgameLabel.setAlignment(Align.center);
endgameLabel.setPosition(1920 / 2 - 300, 1080 / 1.5f);
stage.addActor(endgameLabel);
}
示例5: ActionDialog
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public ActionDialog(Label text, Action action, I18NBundle bundle, Skin skin, Hexpert hexpert) {
super(hexpert, skin);
this.action = action;
getBackground().setMinWidth(1000);
getBackground().setMinHeight(400);
text.setWrap(true);
text.setAlignment(Align.center);
getContentTable().add(text).width(getBackground().getMinWidth()).expandX();
getButtonTable().defaults().width(200).height(120).pad(15);
TextButton textButtonYes = new TextButton(bundle.get("yes"), skin);
getButtonTable().add(textButtonYes);
setObject(textButtonYes, 1);
TextButton textButtonNo = new TextButton(bundle.get("no"), skin);
getButtonTable().add(textButtonNo);
setObject(textButtonNo, null);
}
示例6: InfoMenu
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public InfoMenu(String labelText, boolean back) {
super();
text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE));
text.setAlignment(Align.center, Align.center);
stage.addActor(text);
if (back) {
button = MenuTools.getBackButton(this);
stage.addActor(button);
}
}
示例7: ServerSetupMenu
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public ServerSetupMenu(final Save save) {
super();
title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
saveLabel.setAlignment(Align.center);
port = new TextField("", skin);
port.setMessageText(
Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
start = new TextButton(Localization.get("menu.server.start"), skin);
back = MenuTools.getBackButton(this);
start.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)
: Integer.parseInt(port.getText());
Adapter.setMenu(new ServerRunningMenu(save, p));
}
});
stage.addActor(title);
stage.addActor(saveLabel);
stage.addActor(port);
stage.addActor(start);
stage.addActor(back);
}
示例8: InfoMenu
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public InfoMenu(String labelText, String buttonText) {
super();
text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE));
text.setAlignment(Align.center, Align.center);
button = new TextButton(buttonText, skin);
stage.addActor(text);
stage.addActor(button);
}
示例9: setUpWhoDesignerLabel
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public void setUpWhoDesignerLabel() {
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = AssetsManager.getMediumFont();
whoDesignerLabel = new Label("Elena Kiselova", labelStyle);
whoDesignerLabel.setFontScale(0.065f);
whoDesignerLabel.setSize(Constants.WIDTH, Constants.LARGE_FONT_SIZE * whoDesignerLabel.getFontScaleY() + 1);
whoDesignerLabel.setAlignment(Align.center);
whoDesignerLabel.setPosition(0, designerLabel.getY() - whoDesignerLabel.getHeight() * 2 / 3);
stage.addActor(whoDesignerLabel);
}
示例10: TimeScorer
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public TimeScorer(final Klooni game, GameLayout layout) {
super(game, layout, Klooni.getMaxTimeScore());
highScore = Klooni.getMaxTimeScore();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = game.skin.getFont("font");
timeLeftLabel = new Label("", labelStyle);
timeLeftLabel.setAlignment(Align.center);
layout.updateTimeLeftLabel(timeLeftLabel);
startTime = TimeUtils.nanoTime();
deadTime = startTime + START_TIME;
pausedTimeLeft = -1;
}
示例11: FreeridingDialog
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public FreeridingDialog(final Hexpert hexpert, Skin skin)
{
super(hexpert, skin.get("gold", WindowStyle.class));
getBackground().setMinWidth(1400);
I18NBundle i18N = hexpert.i18NBundle;
Label lblRate = new Label(i18N.get("freerider"), skin.get("bigger", Label.LabelStyle.class));
lblRate.setAlignment(Align.center);
lblRate.setWrap(true);
getContentTable().add(lblRate).width(1200);
TextButton.TextButtonStyle goldenStyle = skin.get("gold", TextButton.TextButtonStyle.class);
TextButton textButtonRate = new TextButton(i18N.get("rate"), goldenStyle);
getButtonTable().add(textButtonRate).width(textButtonRate.getLabelCell().getPrefWidth() + 30);
TextButton textButtonNo = new TextButton(i18N.get("no"), goldenStyle);
getButtonTable().add(textButtonNo);
setObject(textButtonNo, null);
textButtonRate.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
hexpert.playServices.rateGame();
hide();
}
});
setObject(textButtonRate, null);
}
示例12: createErrorMessagePanel
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
private void createErrorMessagePanel(){
_errorMessageLbl = new Label("", Assets._skin);
_errorMessageLbl.setColor(1f , 0.15f , 0.15f , 1f);
_errorMessageLbl.setFontScale(2f);
_errorMessageLbl.setAlignment(Align.center);
_errorMessageLbl.setWidth(Gdx.graphics.getWidth());
_errorMessageLbl.setAlignment(Align.center);
_errorMessageLbl.setPosition(0 , 200);
this.addActor(_errorMessageLbl);
}
示例13: setUpScoreLabel
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public void setUpScoreLabel() {
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = AssetsManager.getMediumFont();
scoreLabel = new Label("" + SCORE, labelStyle);
scoreLabel.setFontScale(0.065f);
scoreLabel.setSize(scoreLabel.getWidth() * scoreLabel.getFontScaleX(), scoreLabel.getHeight() * scoreLabel.getFontScaleY());
scoreLabel.setPosition(Constants.WIDTH / 2 - scoreLabel.getWidth() / 2, Constants.HEIGHT * 4 / 5 - scoreLabel.getHeight() / 2);
scoreLabel.setAlignment(Align.center);
stage.addActor(scoreLabel);
}
示例14: setUpWhoDeveloperLabel
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public void setUpWhoDeveloperLabel() {
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = AssetsManager.getMediumFont();
whoDeveloperLabel = new Label("Alexander Klimenko", labelStyle);
whoDeveloperLabel.setFontScale(0.065f);
whoDeveloperLabel.setSize(Constants.WIDTH, Constants.LARGE_FONT_SIZE * whoDeveloperLabel.getFontScaleY() + 1);
whoDeveloperLabel.setAlignment(Align.center);
whoDeveloperLabel.setPosition(0, developerLabel.getY() - whoDeveloperLabel.getHeight() * 2 / 3);
stage.addActor(whoDeveloperLabel);
}
示例15: buildKnight
import com.badlogic.gdx.scenes.scene2d.ui.Label; //导入方法依赖的package包/类
public MultiStepMove buildKnight() {
Stage sessionStage = sessionScreen.aSessionStage;
Stage gamePiecesStage = sessionScreen.gamePiecesStage;
// Make sure the player has everything required to build a knight
if (!knightController.requestBuildKnight()) {
sessionScreen.addGameMessage("You can't build a knight (not enough resources or no valid positions)");
return null;
}
// Create the highlighted positions showing where a knight could be placed
List<CoordinatePair> validBuildKnightPositions = sessionController.getValidBuildKnightPositions();
// List<CoordinatePair> validBuildKnightPositions = sessionController.requestValidInitializationBuildIntersections();
if (validBuildKnightPositions.isEmpty()) {
Label msg = new Label("There are no valid positions\nwhere you can build a knight.", CatanGame.skin);
msg.setAlignment(Align.center);
new Dialog("Warning", CatanGame.skin)
.text(msg)
.button("OK")
.show(sessionStage);
return null;
}
for (CoordinatePair position : validBuildKnightPositions) {
validIntersections.add(position);
CoordinatePair intersection = CoordinatePair.of(
boardOrigin.getLeft() + position.getLeft() * OFFX,
boardOrigin.getRight() + position.getRight() * -LENGTH / 2, null);
Image knightPosition = gamePieces.createKnightPosition(sessionController.getLocalPlayer());
knightPosition.setPosition(intersection.getLeft() - knightPosition.getOriginX(),
intersection.getRight() - knightPosition.getOriginY());
gamePiecesStage.addActor(knightPosition);
highlightedPositions.add(knightPosition);
}
// Create a new multi-step move to allow the player to place a knight
MultiStepMove move = new MultiStepMove();
startMove();
// Make the current move place a knight at the specified position
move.<CoordinatePair>addMove(chosenIntersection -> {
// Clear the highlighted positions
endMove();
// Build the knight
KnightActor knightActor = knightController.buildKnight(chosenIntersection);
sessionScreen.addKnight(knightActor);
// Mark the coordinate position as occupied
chosenIntersection.putKnight(knightActor.getKnight());
});
return move;
}