本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.getPrefWidth()
方法的一些代码示例,展示了Label.getPrefWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.getPrefWidth()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Label
类名称:Label
方法名:getPrefWidth
暂无
代码示例来源:origin: libgdx/libgdx
public Label (CharSequence text, LabelStyle style) {
if (text != null) this.text.append(text);
setStyle(style);
if (text != null && text.length() > 0) setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: libgdx/libgdx
public Label (CharSequence text, LabelStyle style) {
if (text != null) this.text.append(text);
setStyle(style);
if (text != null && text.length() > 0) setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: langurmonkey/gaiasky
@Override
public float getPrefWidth() {
if (ownwidth != 0) {
return ownwidth;
} else {
return super.getPrefWidth();
}
}
代码示例来源:origin: com.github.xaguzman/gamedevlib-libgdx
public float getPrefWidth () {
return Math.max(super.getPrefWidth(), titleLabel.getPrefWidth() + getPadLeft() + getPadRight());
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public Label (CharSequence text, LabelStyle style) {
if (text != null) this.text.append(text);
setStyle(style);
if (text != null && text.length() > 0) setSize(getPrefWidth(), getPrefHeight());
}
代码示例来源:origin: xietansheng/Game2048ForGDX
public void setScore(int score) {
this.score = score;
scoreLabel.setText("" + this.score);
// 重新设置文本后, 文本的宽度可能被改变, 需要重新设置标签的宽度, 并重新水平居中
scoreLabel.setWidth(scoreLabel.getPrefWidth());
scoreLabel.setX(getWidth() / 2 - scoreLabel.getWidth() / 2);
}
代码示例来源: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: lycying/c2d-engine
public void show(boolean isBoss, String text) {
this.clear();
if (isBoss) {
String[] strs = text.split("");
float width = 0;
for (int i = 0; i < strs.length; i++) {
String s = strs[i];
Label temp = new Label(s, new LabelStyle(Engine.resource("Font", BitmapFont.class), Color.WHITE));
temp.setPosition(width, 400);
temp.addAction(Actions.delay(0.1f * i, Actions.sequence(Actions.moveBy(0, -300, 0.5f, Interpolation.swingOut), Actions.delay(1f, Actions.moveBy(0, 300, 0.3f)))));
this.addActor(temp);
width += temp.getPrefWidth();
}
this.setPosition(Engine.getWidth() / 2 - width / 2, 100);
} else {
Label battleLabel = new Label(text, new LabelStyle(Engine.resource("Font", BitmapFont.class), Color.WHITE));
this.setSize(battleLabel.getPrefWidth(), battleLabel.getPrefHeight());
this.setPosition(Engine.getWidth() / 2 - battleLabel.getPrefWidth() / 2, 200);
this.setOrigin(this.getWidth() / 2, this.getHeight() / 2);
this.setScale(0);
this.addAction(sequence(scaleTo(1, 1, 1f, Interpolation.swingOut), delay(1f), Actions.moveBy(50, 0, 0.1f), Actions.moveBy(-1500, 0, 0.3f)));
this.addActor(battleLabel);
}
}
}
代码示例来源: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: 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: xietansheng/Game2048ForGDX
numLabel.setWidth(numLabel.getPrefWidth());
numLabel.setX(getWidth() / 2 - numLabel.getWidth() / 2);
代码示例来源:origin: xietansheng/Game2048ForGDX
numLabel.setSize(numLabel.getPrefWidth(), numLabel.getPrefHeight());
代码示例来源:origin: xietansheng/Game2048ForGDX
msgLabel.setSize(msgLabel.getPrefWidth(), msgLabel.getPrefHeight());
msgLabel.setX(getWidth() / 2 - msgLabel.getWidth() / 2);
msgLabel.setY(okButton.getY() + okButton.getHeight() + 50);
内容来源于网络,如有侵权,请联系作者删除!