本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.Align類的典型用法代碼示例。如果您正苦於以下問題:Java Align類的具體用法?Java Align怎麽用?Java Align使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Align類屬於com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了Align類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addTab
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public void addTab(String tabTitle, final ITabContent tabContent,
Skin skin) {
TextButton button = new TextButton(tabTitle, skin);
button.align(Align.left);
//button.setFillParent(true);
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
tabContent.setContent(content);
content.pack();
setWidth(preferedContentWidth);
setHeight(preferedContentHeight);
}
});
tabHeaders.add(button);
contents.add(tabContent);
preferedContentWidth = Math.max(preferedContentWidth, tabContent.getWidth());
preferedContentHeight = Math.max(preferedContentHeight, tabContent.getHeight() + tabHeaders.get(0).getHeight());
}
示例2: create
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
@Override
public void create () {
if (app == null) {
app = Gdx.app;
tests[testIndex].create();
}
cameraController = new CameraInputController(tests[testIndex].camera);
cameraController.activateKey = Keys.CONTROL_LEFT;
cameraController.autoUpdate = false;
cameraController.forwardTarget = false;
cameraController.translateTarget = false;
Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
hud = new Stage();
hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
fpsLabel.setPosition(0, 0);
hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
instructLabel.setAlignment(Align.top | Align.left);
instructLabel.setText(tests[testIndex].instructions);
}
示例3: create
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
@Override
public void create () {
pref = Gdx.app.getPreferences("DATA");
highScore = pref.getInteger("Score", -1);
if (highScore == -1) {
highScore = 0;
pref.putInteger("Score", 0);
pref.flush();
}
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("ChicagoFLF.fnt"));
//font.setScale(5f);
labelStyle = new Label.LabelStyle(font, new Color(124 / 255.0f, 199 / 255.0f, 72 / 255.0f, 1));
highScoreWordsLabel = new Label("Score:\n\nHigh Score:", labelStyle);
highScoreWordsLabel.setFontScale(0.7f);
highScoreWordsLabel.setHeight((float) highScoreWordsLabel.getHeight() * 0.7f);
highScoreWordsLabel.setPosition(0, VIRTUAL_HEIGHT - highScoreWordsLabel.getHeight());
highScoreWordsLabel.setAlignment(Align.left);
//debugRenderer = new Box2DDebugRenderer();
Assets.load();
this.setScreen(new GameScreen(this));
}
示例4: updateRunning
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public void updateRunning (float delta) {
world.step(delta, 6, 2);
timeGap += delta;
playTime += delta;
if (timeGap >= SQUARE_FALL_INTERVAL) {
createEnemy();
timeGap -= SQUARE_FALL_INTERVAL;
}
if (state == GAME_RUNNING) {
//scoreLabel.addAction(Actions.moveTo(540, 990, 1f));
scoreLabel.setText((Integer.toString((int) playTime)));
//scoreLabel.setPosition(0, 0);
scoreLabel.setPosition(VIRTUAL_WIDTH - scoreLabel.getWidth(), VIRTUAL_HEIGHT - scoreLabel.getHeight());
scoreLabel.setAlignment(Align.right);
//scoreLabel.setVisible(true);
//stage.addActor(scoreLabel);
//logger.info("scoreLabel text: ".concat(scoreLabel.getText().toString()));
//logger.info("score: ".concat((Integer.toString((int) (playTime)))));
}
}
示例5: gameOverSetup
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public void gameOverSetup () {
retry = new Retry();
retry.getColor().a = 0;
retry.addAction(Actions.parallel(Actions.fadeIn(1f),Actions.moveTo(RETRY_X * 100, RETRY_Y * 100, 1f, Interpolation.bounceOut)));
stage.addActor(retry);
retry.setZIndex(50);
if ((int) playTime > game.highScore) {
game.highScore = (int) playTime;
game.pref.putInteger("Score", game.highScore);
game.pref.flush();
}
highScoreLabel = new Label(Integer.toString(game.highScore), game.labelStyle);
highScoreLabel.setFontScale(1.5f);
highScoreLabel.setPosition(VIRTUAL_WIDTH - highScoreLabel.getWidth(), VIRTUAL_HEIGHT - highScoreLabel.getHeight() - 300);
highScoreLabel.setAlignment(Align.right);
stage.addActor(highScoreLabel);
stage.addActor(game.highScoreWordsLabel);
highScoreLabel.getColor().a = game.highScoreWordsLabel.getColor().a = 0;
highScoreLabel.setZIndex(50);
game.highScoreWordsLabel.setZIndex(50);
highScoreLabel.addAction(Actions.fadeIn(0.25f));
game.highScoreWordsLabel.addAction(Actions.fadeIn(0.25f));
}
示例6: show
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
@Override
public void show() {
stage = new Stage();
table = new Table();
float padding = 50 * scale;
BitmapFont font = new BitmapFont(Gdx.files.internal("fonts/deja_vu_sans_medium.fnt"));
Vector2 screenSize = new Vector2(Gdx.graphics.getWidth()
, Gdx.graphics.getHeight());
font.setScale(scale);
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
messageLabel = new Label(text, labelStyle);
messageLabel.setWrap(true);
messageLabel.setWidth(screenSize.x - padding * 2);
messageLabel.setAlignment(Align.center);
table.setFillParent(true);
table.defaults().pad(padding);
table.add(messageLabel)
.width(screenSize.x - padding * 2);
stage.addActor(table);
}
示例7: GameResultScreen
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public GameResultScreen(Context context, String winner) {
super(context.app);
hasPlayerWon = context.getPlayerNickname().equals(winner);
String text = hasPlayerWon ? "You have won!" : "Player " + winner + " has won.";
Label label = new Label(text, app.skin);
label.setAlignment(Align.center);
mainTable.add(label).expand().fill();
if (hasPlayerWon) {
leftSystem = new ParticleSystem("winner.ps");
rightSystem = new ParticleSystem("winner.ps");
leftSystem.setPosition(Gdx.graphics.getWidth() / 4, Gdx.graphics.getHeight() / 2);
rightSystem.setPosition(Gdx.graphics.getWidth() / 4 * 3, Gdx.graphics.getHeight() / 2);
addActor(leftSystem);
addActor(rightSystem);
}
mainTable.layout();
}
示例8: ImageTextButton
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public ImageTextButton (String text, ImageTextButtonStyle style) {
super(style);
this.style = style;
defaults().space(3);
image = new Image();
image.setScaling(Scaling.fit);
add(image);
label = new Label(text, new LabelStyle(style.font, style.fontColor));
label.setAlignment(Align.center);
add(label);
setStyle(style);
setSize(getPrefWidth(), getPrefHeight());
}
示例9: reset
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
/** Removes all actors and cells from the table (same as {@link #clear()}) and additionally resets all table properties and
* cell, column, and row defaults. */
public void reset () {
clear();
padTop = backgroundTop;
padLeft = backgroundLeft;
padBottom = backgroundBottom;
padRight = backgroundRight;
align = Align.center;
debug(Debug.none);
cellDefaults.defaults();
for (int i = 0, n = columnDefaults.size; i < n; i++) {
Cell columnCell = columnDefaults.get(i);
if (columnCell != null) cellPool.free(columnCell);
}
columnDefaults.clear();
}
示例10: layout
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public void layout () {
if (drawable == null) return;
float regionWidth = drawable.getMinWidth();
float regionHeight = drawable.getMinHeight();
float width = getWidth();
float height = getHeight();
Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
imageWidth = size.x;
imageHeight = size.y;
if ((align & Align.left) != 0)
imageX = 0;
else if ((align & Align.right) != 0)
imageX = (int)(width - imageWidth);
else
imageX = (int)(width / 2 - imageWidth / 2);
if ((align & Align.top) != 0)
imageY = (int)(height - imageHeight);
else if ((align & Align.bottom) != 0)
imageY = 0;
else
imageY = (int)(height / 2 - imageHeight / 2);
}
示例11: ProgressPanel
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public ProgressPanel() {
super();
messagesUsed = Sets.newHashSet();
loadingMessage = FontManager.Roboto32.makeLabel(selectRandomMessage(), Color.WHITE, Align.center);
loadingMessage.setColor(Color.DARK_GRAY);
loadingMessage.setAlignment(Align.center);
progressLabel = FontManager.Roboto64.makeLabel("0%", Color.WHITE, Align.center);
progressLabel.setColor(Color.DARK_GRAY);
progressLabel.setAlignment(Align.center);
row();
add(loadingMessage).center();
row();
add(progressLabel).center();
}
示例12: show
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
protected void show(Actor parentWidget, Actor relativeTo) {
setVisible(true);
content.setVisible(true);
parentWidget.getStage().addActor(this);
parentWidget.getStage().addActor(content);
content.pack();
pack();
float relativeX = relativeTo.getX() + parentWidget.getX();
if ((arrowAlignment & Align.right) != 0) {
setX(relativeX - getWidth() + relativeTo.getWidth() - ((relativeTo.getWidth() - triangle.getWidth()) / 2) + 8);
} else {
setX(relativeX + ((relativeTo.getWidth() - triangle.getWidth()) / 2) - 8);
}
setY(relativeTo.getY() + parentWidget.getY() - getHeight() - relativeTo.getHeight() / 2);
content.setX(getX() + Display.devicePixel(10));
content.setY(getY() + Display.devicePixel(10));
InputSystem.instance().bind(new int[] { ESCAPE, BACK }, inputCallback);
InputSystem.instance().addInputProcessor(clickCallback, 0);
addAction(Actions.fadeIn(BUTTON_FADE_DURATION));
content.addAction(Actions.fadeIn(BUTTON_FADE_DURATION));
}
示例13: addRequirement
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void addRequirement(Requirement requirement) {
row().fillX().pad(12, 0, 12, 0);
Label label = Roboto18.makeLabel(requirement.displayString());
label.setWrap(true);
add(label).expandX();
Cell amountCell = add().center();
if (requirement.getAmount() > 0) {
Label amountValue = RobotoBold18.makeLabel(String.format("%d/%d", requirement.getCurrentWeight(), requirement.getAmount()));
amountValue.setAlignment(Align.center);
amountCell.setWidget(amountValue);
}
ProgressBar progressBar = new ProgressBar(requirement.getProgress());
add(progressBar).width(200).right().center();
row();
add(new HorizontalRule(Color.DARK_GRAY, 1)).colspan(3);
}
示例14: RatingBar
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
public RatingBar(float stars, int maxValue) {
super();
this.stars = stars;
this.maxValue = maxValue;
defaults().left().space(Display.devicePixel(2));
setTextures(STAR_ICON);
starPlaceholder = new NoOpWidget();
valueLabel = FontManager.RobotoBold18.makeLabel("5.0");
valueLabel.setAlignment(Align.center);
setValue(stars);
textureHeight = maskTexture.getHeight();
updateLayout();
}
示例15: initializeUiElements
import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入依賴的package包/類
/**
* Initialisiert die UI-Elemente.
*/
private void initializeUiElements() {
DefaultScrollPane tableContainer;
tableWidth = width - 150;
tableHeight = height - 300;
lootTable = new VerticalGroup();
lootTable.space(10);
lootTable.align(Align.left + Align.top);
lootTable.setWidth(tableWidth);
tableContainer = new DefaultScrollPane(lootTable, tableHeight,
tableWidth);
tableContainer.setPosition(75, 50);
tableContainer.toFront();
stage.addActor(tableContainer);
// switch button erstellen
stage.addActor(createSwitchButton());
}