本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.GlyphLayout.setText方法的典型用法代码示例。如果您正苦于以下问题:Java GlyphLayout.setText方法的具体用法?Java GlyphLayout.setText怎么用?Java GlyphLayout.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.GlyphLayout
的用法示例。
在下文中一共展示了GlyphLayout.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawPlayerNames
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
void drawPlayerNames(){
GlyphLayout layout = Pools.obtain(GlyphLayout.class);
Draw.tscl(0.25f/2);
for(Player player : Vars.control.playerGroup.all()){
if(!player.isLocal){
layout.setText(Core.font, player.name);
Draw.color(0f, 0f, 0f, 0.3f);
Draw.rect("blank", player.x, player.y + 8 - layout.height/2, layout.width + 2, layout.height + 2);
Draw.color();
Draw.tcolor(NetClient.colorArray[player.id % NetClient.colorArray.length]);
Draw.text(player.name, player.x, player.y + 8);
Draw.tcolor();
}
}
Pools.free(layout);
Draw.tscl(Vars.fontscale);
}
示例2: draw
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
@Override
public void draw(Batch batch,float parentAlpha){
AssetLoader.font.getData().setScale(getScaleX());
timer+=Gdx.graphics.getDeltaTime();
FPSCount++;
String text="FPS: "+fps;
GlyphLayout layout=new GlyphLayout();
layout.setText(AssetLoader.font, text);
float height=layout.height;
AssetLoader.font.draw(batch, text, 0, height);
if(FPSCount>=60)
{
fps=(int) ((float)FPSCount/timer);
timer=0;
FPSCount=0;
}
}
示例3: show
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
@Override
public void show() {
super.show();
layout = new GlyphLayout();
font = new NativeFont(new NativeFontPaint(25));
font.appendText("正在加载...0123456789%");
font.setColor(Color.BLACK);
layout.setText(font, "正在加载...100%");
stage = new Stage(new StretchViewport(1280, 720));
assetManager = new AssetManager();
assetManager.setLogger(new Logger("log", Logger.DEBUG));
assetManager.setLoader(CocosScene.class, new CocosLoader(new InternalFileHandleResolver()));
assetManager.load("mainscene/MenuScene.json", CocosScene.class);
}
示例4: Button
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public Button(String texture, int x, int y, String content, boolean haveDarkEffect) {
super(texture, x, y);
pressed = false;
justSound = false;
this.content = content;
this.haveDarkEffect = haveDarkEffect;
//Si tenemos un texto para contenido, lo centramos en el botón
if (content != null) {
GlyphLayout layout = new GlyphLayout();
layout.setText(FontManager.text, FontManager.getFromBundle(content));
contentX = x + (this.getWidth() - layout.width) / 2;
contentY = y + (this.getHeight() + layout.height) / 2;
}
}
示例5: initItemsPositions
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
private <E extends Enum<?>> void initItemsPositions(Class<E> menuEnumClass) {
offset = new Vector2(0, 0);
float verticalMenuSize = font.getXHeight() * (menuEnumClass.getEnumConstants().length) + verticalMenuSpacing * (menuEnumClass.getEnumConstants().length - 1);
verticalMenuStart = Gdx.graphics.getHeight() - (Gdx.graphics.getHeight() - verticalMenuSize) / 2;
float letterMaxWidth = 0;
for (E enumValue : menuEnumClass.getEnumConstants()) {
GlyphLayout layout = new GlyphLayout();
layout.setText(font, enumValue.toString());
letterMaxWidth = layout.width > letterMaxWidth ? layout.width : letterMaxWidth;
menuItems.add(new MenuItem(enumValue, new Vector2((Gdx.graphics.getWidth() - layout.width) / 2, 0)));
}
horizontalMenuStart = (Gdx.graphics.getWidth() - letterMaxWidth) / 2;
}
示例6: Button
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public Button(String text, float x, float y, int key) {
font = new BitmapFont();
layout = new GlyphLayout();
this.key = key;
this.text = text;
setX(x);
setY(y);
layout.setText(font, text);
setWidth((2 * offset) + layout.width);
setHeight(11 + (2 * offset));
np = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16);
np_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_hover.png")), 16, 16, 16, 16);
np_checked = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked.png")), 16, 16, 16, 16);
np_checked_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked_hover.png")), 16, 16, 16,
16);
checkbox = false;
checked = false;
}
示例7: renderPauseDialog
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public void renderPauseDialog() {
// Fade to black
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
_shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
_shapeRenderer.setColor(0.05f, 0.05f, 0.05f, 0.5f);
_shapeRenderer.rect(0, 0, GAME_WIDTH, GAME_HEIGHT);
_shapeRenderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
_batch.begin();
// TODO: Factor this out (at the very least)
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font/raleway/Raleway-Medium.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 32;
BitmapFont bfont = generator.generateFont(parameter);
GlyphLayout layout = new GlyphLayout();
bfont.getData().setScale(0.12f, 0.12f);
float x_pos = GAME_WIDTH / 2;
float y_pos = 20 / 2;
bfont.setColor(1.0f, 1.0f, 1.0f, 0.5f);
layout.setText(bfont, Messages.getText("system.exit"));
x_pos -= layout.width / 2;
y_pos += layout.height / 2;
bfont.draw(_batch, layout, x_pos, y_pos);
_batch.end();
}
示例8: draw
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
@Override
public void draw(Batch batch, float delta){
super.draw(batch, delta);
AssetLoader.font.getData().setScale(getScaleX()*0.5f);
GlyphLayout layout=new GlyphLayout();
layout.setText(AssetLoader.font, text);
float width=layout.width;
float height=layout.height;
AssetLoader.font.draw(batch, text, getX()+getWidth()*getScaleX()*0.5f-width*0.5f,
getY()+getHeight()*getScaleY()*0.5f+height*0.5f);
}
示例9: drawTextCentered
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
private void drawTextCentered(Batch batch, String text, float x, float y)
{
GlyphLayout layout=new GlyphLayout();
layout.setText(AssetLoader.font, text);
Vector2 pos=getScaledPos(x,y);
float width=layout.width;
float height=layout.height;
AssetLoader.font.draw(batch, text, pos.x-width*0.5f, pos.y+height*0.5f);
}
示例10: Text
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public Text(String text, float x, float y) {
font = new BitmapFont();
layout = new GlyphLayout();
this.text = text;
layout.setText(font, text);
setX(x);
setY(y);
setWidth(layout.width);
setHeight(11);
bgColorEnabled = false;
this.y = y;
}
示例11: getWidth
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public static int getWidth(BitmapFont font, GlyphLayout bounds, String str) {
bounds.setText(font, str);
int textWidth = (int)bounds.width+1;
// bug in libgdx, doesn't like strings ending with a space,
// it ignores it
if(str.endsWith(" ")) {
textWidth += font.getSpaceWidth();
}
return textWidth;
}
示例12: initAssets
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public void initAssets()
{
TextureAtlas atlas = screen.game.assets.manager.get("data/hud/hud.pack");
back = screen.game.assets.manager.get("data/hud/dialog_background.png");
TextureRegion btnCancel = atlas.findRegion("cancel");
TextureRegion btnAccept = atlas.findRegion("accept");
font = screen.game.assets.manager.get("confirm_dialog.ttf");
fontGlyph = new GlyphLayout();
buttonNo = new Button();
buttonNo.rect.width = dialogWidth * .15f;
buttonNo.rect.height = buttonNo.rect.width;
buttonNo.rect.x = dialogX + dialogWidth * .35f - buttonNo.rect.width * .5f;
buttonNo.rect.y = dialogY - buttonNo.rect.height * .5f;
buttonNo.texture = btnCancel;
buttonYes = new Button(buttonNo);
buttonYes.rect.x = dialogX + dialogWidth * .65f - buttonNo.rect.width * .5f;
buttonYes.texture = btnAccept;
fontGlyph.setText(font, title);
titleR = new Rectangle(contentRect.x + contentRect.width * .5f - fontGlyph.width * .5f,
contentRect.y + contentRect.height,
fontGlyph.width, fontGlyph.height);
fontGlyph.setText(font, text, font.getColor(), contentRect.width, Align.center, true);
//bounds = font.getWrappedBounds(text, dialogWidth - dialogPadding * 2);
float top = titleR.y - titleR.height;
float bottom = buttonNo.rect.y + buttonNo.rect.height;
float centerVer = top - ((top - bottom) * .5f);
textR = new Rectangle(dialogX + dialogWidth * .5f - fontGlyph.width * .5f,
centerVer + fontGlyph.height * .5f,
fontGlyph.width, fontGlyph.height);
}
示例13: updateFiles
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
private void updateFiles(boolean push){
if(push) stack.push(directory);
navigation.setText(directory.toString());
GlyphLayout layout = Pools.obtain(GlyphLayout.class);
layout.setText(Core.font, navigation.getText());
if(layout.width < navigation.getWidth()){
navigation.setCursorPosition(0);
}else{
navigation.setCursorPosition(navigation.getText().length());
}
Pools.free(layout);
files.clearChildren();
FileHandle[] names = getFileNames();
Image upimage = new Image("icon-folder-parent");
TextButton upbutton = new TextButton(".." + directory.toString());
upbutton.clicked(()->{
directory = directory.parent();
updateFiles(true);
});
upbutton.left().add(upimage).padRight(4f).size(14*2);
upbutton.getCells().reverse();
files.top().left().add(upbutton).align(Align.topLeft).fillX().expandX().height(50).pad(2).colspan(2);
upbutton.getLabel().setAlignment(Align.left);
files.row();
ButtonGroup<TextButton> group = new ButtonGroup<TextButton>();
group.setMinCheckCount(0);
for(FileHandle file : names){
if( !file.isDirectory() && !filter.test(file)) continue; //skip non-filtered files
String filename = file.name();
TextButton button = new TextButton(shorten(filename), "toggle");
group.add(button);
button.clicked(()->{
if( !file.isDirectory()){
filefield.setText(filename);
updateFileFieldStatus();
}else{
directory = directory.child(filename);
updateFiles(true);
}
});
filefield.changed(()->{
button.setChecked(filename.equals(filefield.getText()));
});
Image image = new Image(file.isDirectory() ? "icon-folder" : "icon-file-text");
button.add(image).padRight(4f).size(14*2f);
button.getCells().reverse();
files.top().left().add(button).align(Align.topLeft).fillX().expandX()
.height(50).pad(2).padTop(0).padBottom(0).colspan(2);
button.getLabel().setAlignment(Align.left);
files.row();
}
pane.setScrollY(0f);
updateFileFieldStatus();
if(open) filefield.clearText();
}
示例14: create
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public void create () {
font_ = new BitmapFont(Gdx.files.internal("chapter-2/my-font.fnt"));
glyphLayout_ = new GlyphLayout();
glyphLayout_.setText(font_, "Hello World!");
}
示例15: layout
import com.badlogic.gdx.graphics.g2d.GlyphLayout; //导入方法依赖的package包/类
public void layout() {
final BitmapFont font = style.font;
final BitmapFont subfont = style.subtitleFont;
final Drawable selectedDrawable = style.selection;
cellRenderer.layout(style);
GlyphLayout textLayout = new GlyphLayout();
prefWidth = 0;
for (int i = 0; i < items.size; i++) {
textLayout.setText(font, cellRenderer.getCellTitle(items.get(i)));
prefWidth = Math.max(textLayout.width, prefWidth);
if (cellRenderer.hasImage()) {
TextureRegion r = cellRenderer.getCellImage(items.get(i));
float ih = r.getRegionHeight();
float iw = r.getRegionWidth();
if (ih > getItemHeight() - 10) {
ih = getItemHeight() - 10;
iw *= ih / r.getRegionHeight();
}
prefWidth = Math.max(iw + textLayout.width, prefWidth);
}
if (cellRenderer.hasSubtitle()) {
String subtitle = cellRenderer.getCellSubTitle(items.get(i));
if (subtitle != null) {
textLayout.setText(subfont, subtitle);
prefWidth = Math.max(textLayout.width, prefWidth);
}
}
}
prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth();
prefHeight = items.size * cellRenderer.getItemHeight();
Drawable background = style.background;
if (background != null) {
prefWidth += background.getLeftWidth() + background.getRightWidth();
prefHeight += background.getTopHeight() + background.getBottomHeight();
}
}