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);
}
java类com.badlogic.gdx.graphics.g2d.GlyphLayout的实例源码
Renderer.java 文件源码
项目:Mindustry
阅读 27
收藏 0
点赞 0
评论 0
TextActor.java 文件源码
项目:alquran-alkarem
阅读 28
收藏 0
点赞 0
评论 0
public TextActor(String string,Color color,float targetwidth,TextAlign align,float scaleXY ,float x ,float y) {
// TODO Auto-generated constructor stub
font = book.base_font;
text_string = string ;
xpos = x;
ypos = y;
width = targetwidth ;
text_color = (color==null?Color.BLACK:color) ;
this.align = align;
scale = scaleXY;
font.getData().setScale(scaleXY);
//font.setColor(Color.BLUE);
best_score_text_layout = new GlyphLayout(
font,
text_string,
text_color,
width,
this.align == TextAlign.align_cinter?Align.center:(this.align==TextAlign.align_right?Align.right:Align.left),
true);
}
IngameMenu.java 文件源码
项目:school-game
阅读 32
收藏 0
点赞 0
评论 0
/**
* Initialisierung.
*
* @param game Zugriff auf die Spielinstanz
* @param level Zugriff auf die aktive Levelinstanz
*/
public IngameMenu(SchoolGame game, Level level)
{
this.game = game;
this.level = level;
titleFont = game.getTitleFont();
textFont = game.getDefaultFont();
smallFont = game.getLongTextFont();
selectSound = game.getAudioManager().createSound("menu", "select.wav", true);
changeSound = game.getAudioManager().createSound("menu", "change.wav", true);
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
localeBundle = level.getLocaleBundle();
fontLayout = new GlyphLayout();
projection = new Matrix4();
}
NewGameMenu.java 文件源码
项目:school-game
阅读 30
收藏 0
点赞 0
评论 0
public MenuNewSlot(String label, String detail, SaveData saveData)
{
super(label);
this.saveData = saveData;
this.detail = detail;
setCustomRendering(true);
setHeight(100);
used = saveData.isUsed() ? 1 : 0;
id = saveData.getSlot().ordinal() + 1;
playerName = saveData.getPlayerName();
gender = saveData.isMale() ? "M" : "W";
levelName = saveData.getLevelName();
formatPlaytime(saveData.getPlayTime());
fontLayout = new GlyphLayout();
}
MenuState.java 文件源码
项目:school-game
阅读 20
收藏 0
点赞 0
评论 0
/**
* Initialisierung.
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
Gdx.app.getApplicationLogger().log("INFO", "Menu init...");
this.game = game;
entries = new ArrayList<MenuEntry>();
this.setupMenu();
batch = new SpriteBatch();
font = game.getDefaultFont();
fontLayout = new GlyphLayout();
selectSound = game.getAudioManager().createSound("menu", "select.wav", true);
changeSound = game.getAudioManager().createSound("menu", "change.wav", true);
game.getAudioManager().selectMusic(MUSIC_NAME, 0f);
FileHandle baseFileHandle = Gdx.files.internal("data/I18n/" + getI18nName());
localeBundle = I18NBundle.createBundle(baseFileHandle);
Gdx.app.getApplicationLogger().log("INFO", "Menu finished...");
}
Credits.java 文件源码
项目:school-game
阅读 40
收藏 0
点赞 0
评论 0
/**
* Initialisierung.
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
this.game = game;
batch = new SpriteBatch();
font = game.getDefaultFont();
fontLayout = new GlyphLayout();
offset -= Gdx.graphics.getHeight() / 2 - 35;
FileHandle credits = Gdx.files.internal("data/misc/credits.txt");
if (credits.exists() && !credits.isDirectory())
{
prepareCredits(credits);
}
}
CreateGameSlot.java 文件源码
项目:school-game
阅读 32
收藏 0
点赞 0
评论 0
/**
* Initialisierung
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
this.game = game;
saveData = new SaveData(this.game, this.slot);
batch = new SpriteBatch();
font = game.getDefaultFont();
smallFont = game.getLongTextFont();
fontLayout = new GlyphLayout();
FileHandle baseFileHandle = Gdx.files.internal("data/I18n/GameMenu");
localeBundle = I18NBundle.createBundle(baseFileHandle);
}
LoadGameMenu.java 文件源码
项目:school-game
阅读 30
收藏 0
点赞 0
评论 0
public MenuLoadSlot(String label, String detail, SaveData saveData)
{
super(label);
this.saveData = saveData;
this.detail = detail;
setEnabled(saveData.isUsed());
setCustomRendering(true);
setHeight(100);
used = saveData.isUsed() ? 1 : 0;
id = saveData.getSlot().ordinal() + 1;
playerName = saveData.getPlayerName();
gender = saveData.isMale() ? "M" : "W";
levelName = saveData.getLevelName();
formatPlaytime(saveData.getPlayTime());
fontLayout = new GlyphLayout();
}
Crafting.java 文件源码
项目:JGame
阅读 46
收藏 0
点赞 0
评论 0
public Crafting(int x, int y, int wid, int hei) {
this.x = x;
this.y = y;
this.wid = wid;
this.hei = hei;
shapes = new ShapeRenderer();
this.active = true;
fontHandler = new FontHandler();
layoutSave = new GlyphLayout(fontHandler.font32, "SAVE");
widthSave = layoutSave.width;
heightSave = layoutSave.height;
layoutExit = new GlyphLayout(fontHandler.font32, "X");
widthExit = layoutExit.width;
heightExit = layoutExit.height;
}
MainMenu.java 文件源码
项目:JGame
阅读 39
收藏 0
点赞 0
评论 0
public MainMenu(JGame game) {
this.game = game;
this.batch = game.batch;
playY = (game.screenY / 2) + 200;
loadY = (game.screenY / 2) + 100;
exitY = (game.screenY / 2);
shapes = new ShapeRenderer();
fontHandler = new FontHandler();
layoutPlay = new GlyphLayout(fontHandler.font90, "PLAY");
widthPlay = layoutPlay.width;
heightPlay = layoutPlay.height;
layoutLoad = new GlyphLayout(fontHandler.font90, "LOAD");
widthLoad = layoutLoad.width;
heightLoad = layoutLoad.height;
layoutExit = new GlyphLayout(fontHandler.font90, "EXIT");
widthExit = layoutExit.width;
heightExit = layoutExit.height;
}
ProgressRenderSystem.java 文件源码
项目:odb-dynasty
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected void initialize() {
super.initialize();
glyphLayout = new GlyphLayout();
buildLabel = createLabel(12 * G.ZOOM, 4 * G.ZOOM + 18 * G.ZOOM, "FFFFFFFF", "Build progress", "000000FF", 4000);
scoreLabel = createLabel(80 * G.ZOOM, 4 * G.ZOOM + 18 * G.ZOOM, "FFFFFFFF", "Score:", "000000FF", 4000);
progressButton = new DynastyEntityBuilder(world)
.with(Tint.class).with(
new Bounds(0, 0, 26*G.ZOOM, 16*G.ZOOM),
new Clickable(),
new Button("btn-turn-up", "btn-turn-hover", "btn-turn-down", new ButtonListener() {
@Override
public void run() {
progressAlgorithmSystem.progress();
}
})
)
.group("progress")
.anim("btn-test-up")
.renderable(920)
.pos(7 * G.ZOOM + AssetSystem.PROGRESS_BAR_BACKGROUND_WIDTH * G.ZOOM, 4 * G.ZOOM)
.scale(G.ZOOM)
.build();
}
TextArea.java 文件源码
项目:jrpg-engine
阅读 25
收藏 0
点赞 0
评论 0
private List<GlyphLayout> paginateText(final FontSet fontSet, final String text) {
List<GlyphLayout> results = new LinkedList<>();
Queue<String> words = new LinkedList<>();
words.addAll(Arrays.asList(text.split(" ")));
String pageText = null;
GlyphLayout layout = generateGlyphLayout(fontSet, "");
while (!words.isEmpty()) {
pageText = (pageText == null) ? words.peek() : String.join(" ", pageText, words.peek());
GlyphLayout nextLayout = generateGlyphLayout(fontSet, pageText);
if (nextLayout.height < getHeight()) {
layout = nextLayout;
words.remove();
} else {
results.add(layout);
pageText = null;
layout = generateGlyphLayout(fontSet, "");
}
}
results.add(layout);
return results;
}
TrumpSelectScreen.java 文件源码
项目:OmiClub
阅读 30
收藏 0
点赞 0
评论 0
@Override
public void show() {
Map<String, Sprite> loadingSprites = GraphicsLoader.getCommonBackground();
background = loadingSprites.get("background");
logo = loadingSprites.get("logo_faded");
labelFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 15));
selectTextLayout = new GlyphLayout(labelFont, "Select Trumps");
textX = DimensionHandler.getScreenWidth()/8;
textY = DimensionHandler.getScreenHeight()/6*5;
suits = GraphicsLoader.getSuits();
prepareSuits();
spriteBatch = new SpriteBatch();
stage = new Stage();
stage.clear();
stage.addActor(suits.get(Suit.HEARTS));
stage.addActor(suits.get(Suit.SPADES));
stage.addActor(suits.get(Suit.DIAMONDS));
stage.addActor(suits.get(Suit.CLUBS));
Gdx.input.setInputProcessor(stage);
}
PlayerSelector.java 文件源码
项目:OmiClub
阅读 35
收藏 0
点赞 0
评论 0
@Override
public void show() {
Map<String, Sprite> loadingSprites = GraphicsLoader.getCommonBackground();
background = loadingSprites.get("background");
logo = loadingSprites.get("logo_faded");
labelFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 15));
selectTextLayout = new GlyphLayout(labelFont, "Select Friendly Player");
textX = DimensionHandler.getScreenWidth()/8;
textY = DimensionHandler.getScreenHeight()/6*5;
playerFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 20));
style = new Label.LabelStyle(playerFont, Color.WHITE);
setLabels();
spriteBatch = new SpriteBatch();
stage = new Stage();
stage.clear();
stage.addActor(p1Label);
stage.addActor(p2Label);
stage.addActor(p3Label);
Gdx.input.setInputProcessor(stage);
}
FPSCounter.java 文件源码
项目:ShapeClear
阅读 28
收藏 0
点赞 0
评论 0
@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;
}
}
FontRenderer.java 文件源码
项目:RavTech
阅读 39
收藏 0
点赞 0
评论 0
@Override
public void draw (SpriteBatch batch) {
Matrix4 oldTransformMatrix = batch.getTransformMatrix().cpy();
fontMatrix.set(resetMatrix);
fontMatrix.rotate(Vector3.Z, getParent().transform.getRotation());
Vector2 position = getParent().transform.getPosition();
fontMatrix.trn(position.x, position.y, 0);
batch.setTransformMatrix(fontMatrix);
font.setColor(tint);
font.getData().setScale(0.05f * xScale, 0.05f * yScale);
GlyphLayout layout = font.draw(batch, text, centered ? -xOffset / 2 : 0, centered ? yOffset / 2 : 0);
xOffset = layout.width;
yOffset = layout.height;
batch.setTransformMatrix(oldTransformMatrix);
}
AMScreen.java 文件源码
项目:cocos-ui-libgdx
阅读 30
收藏 0
点赞 0
评论 0
@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);
}
Button.java 文件源码
项目:spacegame
阅读 33
收藏 0
点赞 0
评论 0
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;
}
}
AbstractMenuScreen.java 文件源码
项目:Mario-Libgdx
阅读 24
收藏 0
点赞 0
评论 0
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;
}
PantallaMenu.java 文件源码
项目:test01
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void show() {
// TODO Auto-generated method stub
img_ini01 = new Texture("T120SOFT_02.png");
p_width = Gdx.graphics.getWidth();
p_height = Gdx.graphics.getHeight();
camara = new OrthographicCamera(p_width,p_height);
layout = new GlyphLayout();
fuente = new BitmapFont(Gdx.files.internal("font001.fnt"),false);
str_inicio[0] = " T120 Soft Apps ";
str_inicio[1] = "EMPEZAR";
str_inicio[2] = "OPCIONES";
str_inicio[3] = "SALIR";
count = 0;
}
PantallaInicio.java 文件源码
项目:test01
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void show() {
// TODO Auto-generated method stub
img_ini01 = new Texture("T120SOFT_01.png");
p_width = Gdx.graphics.getWidth();
p_height = Gdx.graphics.getHeight();
camara = new OrthographicCamera(p_width,p_height);
layout = new GlyphLayout();
fuente = new BitmapFont(Gdx.files.internal("font000.fnt"),false);
str_inicio[0] = " T120 Soft Apps ";
str_inicio[1] = "Pulsa para continuar";
count = 0;
}
PantallaJuego.java 文件源码
项目:test01
阅读 30
收藏 0
点赞 0
评论 0
@Override
public void show() {
// TODO Auto-generated method stub
img_ini01 = new Texture("T120SOFT_01.png");
p_width = Gdx.graphics.getWidth();
p_height = Gdx.graphics.getHeight();
camara = new OrthographicCamera(p_width,p_height);
layout = new GlyphLayout();
fuente = new BitmapFont(Gdx.files.internal("font000.fnt"),false);
str_inicio[0] = " T120 Soft Apps ";
str_inicio[1] = "Pulsa para continuar";
count = 0;
}
Button.java 文件源码
项目:KittenMaxit
阅读 28
收藏 0
点赞 0
评论 0
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;
}
Button.java 文件源码
项目:KittenMaxit
阅读 39
收藏 0
点赞 0
评论 0
public Button(String text, float x, float y) {
font = new BitmapFont();
layout = new GlyphLayout();
this.text = text;
setX(x);
setY(y);
key = -1;
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;
}
NerdShooter.java 文件源码
项目:NerdShooter
阅读 23
收藏 0
点赞 0
评论 0
public void create() {
shooter = this;
if(Gdx.app.getType() == Application.ApplicationType.Android){
GUI_SCALE = 0.75F;
}
layout = new GlyphLayout();
prefs = Gdx.app.getPreferences("settings");
reloadSettings();
keys = (int[])InterScreenData.getInstance("desktop_keys").getData();
if(keys != null){
useKeys = true;
} else {
useKeys = false;
}
setScreen(new SplashScreen());
new CompletedLevel();
new OptionsScreen();
new DownloadScreen();
new PackScreen();
}
TextBoxRenderSystem.java 文件源码
项目:ShapeOfThingsThatWere
阅读 21
收藏 0
点赞 0
评论 0
private Texture preprocess(Entity e) {
TextBox box = boxes.get(e);
box.text = box.generator.get();
Empire empire = empires.get(e);
GlyphLayout bounds = font.getCache().setText(box.text, 0, 0);
Pixmap pm = new Pixmap((int) bounds.width + PAD * 2, (int) bounds.height + PAD * 2, Pixmap.Format.RGBA8888);
pm.setColor(empire.backColor);
pm.fill();
pm.setColor(empire.color);
pm.drawRectangle(0, 0, pm.getWidth(), pm.getHeight());
box.texture = new Texture(pm);
box.color = empire.color;
return box.texture;
}
MainMenuScreen.java 文件源码
项目:SMC-Android
阅读 25
收藏 0
点赞 0
评论 0
public MainMenuScreen(MaryoGame game)
{
super(game);
this.game = game;
batch = new SpriteBatch();
drawCam = new OrthographicCamera(Constants.MENU_CAMERA_WIDTH, Constants.MENU_CAMERA_HEIGHT);
drawCam.position.set(Constants.MENU_CAMERA_WIDTH / 2 + (Constants.MENU_DRAW_WIDTH - Constants.MENU_CAMERA_WIDTH) / 2, Constants.MENU_CAMERA_HEIGHT / 2, 0);
drawCam.update();
debugCam = new OrthographicCamera(1280, 720);
debugCam.position.set(1280 / 2, 720 / 2, 0);
debugCam.update();
hudCam = new OrthographicCamera(screenWidth, screenHeight);
hudCam.position.set(screenWidth / 2, screenHeight / 2, 0);
hudCam.update();
loader = new LevelLoader("main_menu");
debugFont = new BitmapFont();
debugFont.setColor(Color.RED);
debugFont.getData().setScale(1.3f);
debugGlyph = new GlyphLayout();
world = new World(this);
selectionAdapter = new SelectionAdapter(loadSelectionItems(), this);
exitDialog = new ConfirmDialog(this, hudCam);
settingsDialog = new SettingsDialog(this, hudCam);
}
CampaignScreen.java 文件源码
项目:Tower-Defense-Galaxy
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void show() {
super.show();
layout = new GlyphLayout();
tempVector = new Vector3();
campaignWorlds = new ArrayList<CampaignWorld>();
campaignWorlds.add(new CampaignWorld(new Texture("theme/basic/Icon.png"), "World 0's Name", "Put description here for basic"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 1","Put description here for fallback1"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 2","Put description here for fallback2"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 3","Put description here for fallback3"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 4","Put description here for fallback4"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 5","Put description here for fallback5"));
campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 6","Put description here for fallback6"));
halfFreeWidth = (int)((viewport.getWorldWidth() - ICON_SIZE) / 2);
segmentWidth = ICON_SIZE + halfFreeWidth;
length = segmentWidth * (campaignWorlds.size() - 1);
background = new Texture("menus/Background_Campaign.png");
textBack = new Texture("menus/text_back_campaign.png");
addDisposables(background, textBack);
addInputProcessor(this);
}
SlotActor.java 文件源码
项目:Cubes_2
阅读 41
收藏 0
点赞 0
评论 0
public static void drawText(Batch batch, float x, float y, ItemStack itemStack) {
if (itemStack == null || itemStack.item.getStackCountMax() == 1) return;
BitmapFontCache cache = Fonts.smallHUD.getCache();
cache.clear();
GlyphLayout layout = cache.addText(Integer.toString(itemStack.count), x, y, 32f, Align.right, false);
cache.translate(0, layout.height);
cache.draw(batch);
}
IntegerSetting.java 文件源码
项目:Cubes_2
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
BitmapFontCache cache = Fonts.hud.getCache();
cache.clear();
GlyphLayout layout = cache.addText(String.format(format, getValue()), getX(), getY(), getWidth(), Align.center, false);
cache.translate(0, (layout.height / 2) + (getHeight() / 2));
cache.draw(batch);
}