com.badlogic.gdx.scenes.scene2d.ui.Label.setY()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.setY()方法的一些代码示例,展示了Label.setY()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setY()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Label
类名称:Label
方法名:setY

Label.setY介绍

暂无

代码示例

代码示例来源: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: xietansheng/Game2048ForGDX

public void setGameOverState(boolean isWin, int score) {
  if (isWin) {
    msgLabel.setText("恭喜您 , 游戏过关 !\n分数: " + score);
  } else {
    msgLabel.setText("游戏结束 !\n分数: " + score);
  }
  
  /*
   * 设置了文本后重新设置标签的宽高以及位置
   */
  // 标签包裹字体
  msgLabel.setSize(msgLabel.getPrefWidth(), msgLabel.getPrefHeight());
  
  msgLabel.setX(40);
  msgLabel.setY(getHeight() - msgLabel.getHeight() - 100);
}

代码示例来源:origin: xietansheng/Game2048ForGDX

private void init(TextureRegion bgRegion) {
  // 首先设置组的宽高(以背景的宽高作为组的宽高)
  setSize(bgRegion.getRegionWidth(), bgRegion.getRegionHeight());
  /*
   * 背景
   */
  bgImage = new Image(bgRegion);
  addActor(bgImage);
  /*
   * 分数文本显示的标签
   */
  // 创建标签样式
  Label.LabelStyle style = new Label.LabelStyle();
  style.font = getMainGame().getBitmapFont();
  
  // 创建文本标签
  scoreLabel = new Label("" + score, style);
  
  // 设置字体缩放
  scoreLabel.setFontScale(0.4F);
  
  // 设置标签的宽高(把标签的宽高设置为文本字体的宽高, 即标签包裹文本)
  scoreLabel.setSize(scoreLabel.getPrefWidth(), scoreLabel.getPrefHeight());
  
  // 设置文本标签在组中水平居中显示
  scoreLabel.setX(getWidth() / 2 - scoreLabel.getWidth() / 2);
  scoreLabel.setY(18);
  
  addActor(scoreLabel);
}

代码示例来源:origin: kbz/SIFTrain

@Override
public void show() {
  float scaleFactor = stage.getHeight() / GlobalConfiguration.BASE_HEIGHT;
  backgroundImage.setSize(stage.getWidth(), stage.getHeight());
  loadingProgress.setSize(stage.getWidth() * 0.7f, stage.getHeight() * 0.07f);
  loadingProgress.setX(stage.getWidth() * 0.15f);
  loadingProgress.setY(stage.getHeight() * 0.1f);
  infoLabel.setX(stage.getWidth() * 0.1f);
  infoLabel.setY(stage.getHeight() * 0.2f);
  infoLabel.setWrap(true);
  infoLabel.setWidth(stage.getWidth() * 0.8f);
  infoLabel.setHeight(stage.getHeight() * 0.7f);
  infoLabel.setFontScale(scaleFactor);
  stage.addActor(backgroundImage);
  stage.addActor(loadingProgress);
  stage.addActor(infoLabel);
}

代码示例来源:origin: xietansheng/Game2048ForGDX

numLabel.setY(getHeight() / 2 - numLabel.getHeight() / 2);

代码示例来源:origin: kbz/SIFTrain

versionLabel.setFontScale(fontScale / 2f);
versionLabel.setX(stage.getWidth() * 0.075f);
versionLabel.setY(stage.getHeight() * 0.9f);
tipLabel.setWrap(true);
tipLabel.setX(stage.getWidth() * 0.10f);
tipLabel.setY(stage.getHeight() * 0.15f);
tipLabel.setWidth(stage.getWidth() * 0.8f);
tipLabel.setAlignment(Align.center);

代码示例来源:origin: kbz/SIFTrain

stage.addActor(splashImage);
titleLabel.setX(stage.getWidth() / 2 - titleLabel.getWidth() / 2);
titleLabel.setY(stage.getHeight() - stage.getHeight() * 0.3f);
titleLabel.setFontScale(fontScale);

代码示例来源:origin: xietansheng/Game2048ForGDX

msgLabel.setY(okButton.getY() + okButton.getHeight() + 50);
addActor(msgLabel);

相关文章