本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.getPrefHeight()
方法的一些代码示例,展示了Label.getPrefHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.getPrefHeight()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Label
类名称:Label
方法名: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: 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
float prefHeight = getPrefHeight();
if (prefHeight != lastPrefHeight) {
lastPrefHeight = prefHeight;
代码示例来源:origin: libgdx/libgdx
float prefHeight = getPrefHeight();
if (prefHeight != lastPrefHeight) {
lastPrefHeight = prefHeight;
代码示例来源:origin: langurmonkey/gaiasky
@Override
public float getPrefHeight() {
if (ownheight != 0) {
return ownheight;
} else {
return super.getPrefHeight();
}
}
代码示例来源: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: 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 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: xietansheng/Game2048ForGDX
numLabel.setSize(numLabel.getPrefWidth(), numLabel.getPrefHeight());
代码示例来源: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: com.badlogicgames.gdx/gdx
float prefHeight = getPrefHeight();
if (prefHeight != lastPrefHeight) {
lastPrefHeight = prefHeight;
代码示例来源:origin: xietansheng/Game2048ForGDX
msgLabel.setSize(msgLabel.getPrefWidth(), msgLabel.getPrefHeight());
msgLabel.setX(getWidth() / 2 - msgLabel.getWidth() / 2);
msgLabel.setY(okButton.getY() + okButton.getHeight() + 50);
内容来源于网络,如有侵权,请联系作者删除!