本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.setPosition()
方法的一些代码示例,展示了Label.setPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setPosition()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Label
类名称:Label
方法名:setPosition
暂无
代码示例来源:origin: libgdx/libgdx
vertexCountLabel.setPosition(0, fpsLabel.getTop());
hud.addActor(vertexCountLabel);
textureBindsLabel.setPosition(0, vertexCountLabel.getTop());
hud.addActor(textureBindsLabel);
shaderSwitchesLabel.setPosition(0, textureBindsLabel.getTop());
hud.addActor(shaderSwitchesLabel);
drawCallsLabel.setPosition(0, shaderSwitchesLabel.getTop());
hud.addActor(drawCallsLabel);
glCallsLabel.setPosition(0, drawCallsLabel.getTop());
hud.addActor(glCallsLabel);
lightsLabel.setPosition(0, glCallsLabel.getTop());
hud.addActor(lightsLabel);
代码示例来源:origin: libgdx/libgdx
@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);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
spriteBatch = new SpriteBatch();
// font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
// font = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")).generateFont(new FreeTypeFontParameter());
font.getData().markupEnabled = true;
font.getData().breakChars = new char[] {'-'};
multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt"));
// Add user defined color
Colors.put("PERU", Color.valueOf("CD853F"));
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
stage = new Stage(new ScreenViewport());
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
BitmapFont labelFont = skin.get("default-font", BitmapFont.class);
labelFont.getData().markupEnabled = true;
// Notice that the last [] has been deliberately added to test the effect of excessive pop operations.
// They are silently ignored, as expected.
label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>", skin);
label.setPosition(100, 200);
stage.addActor(label);
Window window = new Window("[RED]Multicolor[GREEN] Title", skin);
window.setPosition(400, 300);
window.pack();
stage.addActor(window);
layout = new GlyphLayout();
}
代码示例来源:origin: libgdx/libgdx
fps.setPosition(10, 30);
fps.setColor(0, 1, 0, 1);
ui.addActor(fps);
代码示例来源:origin: libgdx/libgdx
statusLabel.setWidth(Gdx.graphics.getWidth() * 0.96f);
statusLabel.setAlignment(Align.center);
statusLabel.setPosition(Gdx.graphics.getWidth() * 0.5f - statusLabel.getWidth() * 0.5f, 30f);
statusLabel.setColor(Color.CYAN);
stage.addActor(statusLabel);
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void repositionShadowLabel() {
float shadowX = getX() + (shiftX * resolutionMult);
float shadowY = getY() - (shiftY * resolutionMult);
shadowLabel.setPosition(shadowX, shadowY);
}
代码示例来源:origin: stackoverflow.com
Label textHalfSize = new Label("Line small 1 of 4\nLine small 2 of 4\nLine small 3 of 4\nLine small 4 of 4", labelStyle);
textHalfSize.setFontScale(0.5f);
textHalfSize.layout();
textHalfSize.setPosition(Gdx.graphics.getWidth()*0.15f, Gdx.graphics.getHeight()-textHalfSize.getPrefHeight());
stage.addActor(textHalfSize);
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
protected void positionChanged() {
super.positionChanged();
if (shadowLabel != null) {
shadowLabel.setPosition(getX() + (shiftX * resolutionMult), getY() - (shiftY * resolutionMult));
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
private static void add(Stage stage, String text) {
msg.clearActions();
msg.setText(text);
GlyphLayout textLayout = new GlyphLayout();
textLayout.setText(msg.getStyle().font, text, Color.BLACK, stage.getWidth() * .8f, Align.center, true);
msg.setSize(textLayout.width + textLayout.height, textLayout.height + textLayout.height * 2);
if (!stage.getActors().contains(msg, true))
stage.addActor(msg);
msg.setPosition(Math.round((stage.getWidth() - msg.getWidth()) / 2),
Math.round((stage.getHeight() - msg.getHeight()) / 2));
msg.invalidate();
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void prepareLabel(AssetsInterface assets) {
Label.LabelStyle labelStyle = new Label.LabelStyle(assets.getFont(this.fontName), Color.WHITE);
if (this.text != null) {
this.progressText = new Label(this.text, labelStyle);
} else {
this.progressText = new Label("", labelStyle);
}
this.progressText.setWidth(this.backgroundImage.getWidth());
this.progressText.setAlignment(Align.center);
this.progressText.setPosition(this.backgroundImage.getX(), (this.backgroundImage.getHeight() - this.progressText.getHeight()) * 0.5f);
}
代码示例来源:origin: LonamiWebs/Klooni1010
ShareScoreScreen(final Klooni game, final Screen lastScreen,
final int score, final boolean timeMode) {
this.game = game;
this.lastScreen = lastScreen;
this.score = score;
this.timeMode = timeMode;
final Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = game.skin.getFont("font_small");
infoLabel = new Label("Generating image...", labelStyle);
infoLabel.setColor(Klooni.theme.textColor);
infoLabel.setAlignment(Align.center);
infoLabel.layout();
infoLabel.setPosition(
(Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
(Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);
spriteBatch = new SpriteBatch();
}
代码示例来源:origin: Var3D/var3dframe
public StageLoad(VGame game) {
super(game);
height = getCutAndHeight();
rend = new ShapeRenderer();
color1 = Color.valueOf("b9b51a");
color2 = Color.valueOf("30883f");
color3 = Color.valueOf("fafd01");
color4 = Color.valueOf("01fd30");
color5 = Color.valueOf("89fc00");
color6 = Color.valueOf("ff2f00");
label = game.getLabel("Loading...").getActor();
label.setPosition(game.getCenterX() - label.getPrefWidth() / 2, height * 0.33f);
addActor(label);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage()
.getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80,
getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: moribitotech/MTX
public void setUpScreenElements() {
// #1.1 TEST
// Set background texture
// #########################################################
setBackgroundTexture(Assets.imgMtxBg);
// #1.2 TEST
// Set back button
// (Override keyBackPressed to do some action see very below)
// #########################################################
setBackButtonActive(true);
// #1.3 TEST
// Screen time / Fps
// Update by overriding render
// #########################################################
lblScreenTime = new Label("", getGame().getAssets().getSkin());
lblFps = new Label("", getGame().getAssets().getSkin());
lblScreenTime.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 40);
lblFps.setPosition(getStage().getWidth() - 80, getStage().getHeight() - 60);
getStage().addActor(lblScreenTime);
getStage().addActor(lblFps);
}
代码示例来源:origin: yichen0831/Bomberman_libGdx
@Override
public void show() {
viewport = new FitViewport(640, 480);
stage = new Stage(viewport, batch);
font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
Label gameOverLabel = new Label("Game Over", labelStyle);
gameOverLabel.setPosition((640 - gameOverLabel.getWidth()) / 2, 226f);
GameManager.getInstance().playMusic("GameOver.ogg", false);
stage.addActor(gameOverLabel);
stage.addAction(Actions.sequence(
Actions.delay(1f),
Actions.fadeOut(2f),
Actions.run(new Runnable() {
@Override
public void run() {
game.setScreen(new MainMenuScreen(game));
}
})));
}
内容来源于网络,如有侵权,请联系作者删除!