本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Label.setSize()
方法的一些代码示例,展示了Label.setSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setSize()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Label
类名称:Label
方法名:setSize
暂无
代码示例来源: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 void setSize(float width, float height) {
ownwidth = width;
ownheight = height;
super.setSize(width, height);
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
protected void sizeChanged() {
super.sizeChanged();
if (shadowLabel != null) {
shadowLabel.setSize(getWidth(), getHeight());
}
}
代码示例来源: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: SquidPony/SquidLib
Label lb = new Label(s, style);
lb.setSize(width * s.length(), height - descent); //+ lineTweak * 1f
lb.setColor(scc.filter(color));
代码示例来源:origin: SquidPony/SquidLib
Label lb = new Label(mut, style);
lb.setSize(width, height - descent); //+ lineTweak * 1f
Color.abgr8888ToColor(lb.getColor(), encodedColor);
代码示例来源:origin: SquidPony/SquidLib
/**
* Converts a char into a Label, or if the argument c is '\0', creates an Image of a solid block. Can be used
* for preparing glyphs for animation effects, and is used internally for this purpose.
* @param c a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.
* @param color a Color to tint c with.
* @return the Actor, with no position set.
*/
public Actor makeActor(char c, Color color) {
if (!initialized) {
throw new IllegalStateException("This factory has not yet been initialized!");
}
if (c == 0) {
Image im = new Image(block);
im.setColor(scc.filter(color));
//im.setSize(width, height - MathUtils.ceil(bmpFont.getDescent() / 2f));
im.setSize(actualCellWidth, actualCellHeight + (distanceField ? 1 : 0)); // - lineHeight / actualCellHeight //+ lineTweak * 1f
// im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
return im;
} else {
mut.setCharAt(0, getOrDefault(c));
Label lb = new Label(mut, style);
lb.setSize(width, height - descent); //+ lineTweak * 1f
lb.setColor(scc.filter(color));
return lb;
}
}
代码示例来源: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: 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: bladecoder/bladecoder-adventure-engine
msg.setAlignment(Align.center, Align.center);
msg.setColor(t.color);
msg.setSize(msg.getWidth() + DPIUtils.getMarginSize() * 2, msg.getHeight() + DPIUtils.getMarginSize() * 2);
代码示例来源:origin: xietansheng/Game2048ForGDX
msgLabel.setSize(msgLabel.getPrefWidth(), msgLabel.getPrefHeight());
msgLabel.setX(getWidth() / 2 - msgLabel.getWidth() / 2);
msgLabel.setY(okButton.getY() + okButton.getHeight() + 50);
内容来源于网络,如有侵权,请联系作者删除!