本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.BitmapFont.draw方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapFont.draw方法的具体用法?Java BitmapFont.draw怎么用?Java BitmapFont.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.BitmapFont
的用法示例。
在下文中一共展示了BitmapFont.draw方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderGuiFpsCounter
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
private void renderGuiFpsCounter(SpriteBatch batch) {
float x = cameraGUI.viewportWidth - 55;
float y = cameraGUI.viewportHeight - 15;
int fps = Gdx.graphics.getFramesPerSecond();
BitmapFont fpsFont = Assets.instance.fonts.defaultNormal;
if (fps >= 45) {
// 45 or more FPS show up in green
fpsFont.setColor(0, 1, 0, 1);
} else if (fps >= 30) {
// 30 or more FPS show up in yellow
fpsFont.setColor(1, 1, 0, 1);
} else {
// less than 30 FPS show up in red
fpsFont.setColor(1, 0, 0, 1);
}
fpsFont.draw(batch, "FPS: " + fps, x, y);
fpsFont.setColor(1, 1, 1, 1);
}
示例2: drawSprite
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
@Override
protected void drawSprite(SpriteBatch batch, float x, float y) {
BitmapFont font = GameCore.getFont();
font.setColor(shadow);
font.draw(batch, text, x-1, y+1, 0, Align.center, false);
font.setColor(main);
font.draw(batch, text, x, y, 0, Align.center, false);
}
示例3: writeOutlinedText
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
public static void writeOutlinedText(BitmapFont font, SpriteBatch batch, String text, float x, float y, Color center, Color outline) {
font.setColor(outline);
font.draw(batch, text, x-1, y-1);
font.draw(batch, text, x-1, y+1);
font.draw(batch, text, x+1, y-1);
font.draw(batch, text, x+1, y+1);
font.setColor(center);
font.draw(batch, text, x, y);
}
示例4: drawText
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
@Override
public void drawText(BitmapFont font,CharSequence text,float X, float Y)
{
font.setUseIntegerPositions(true);
font.draw(getSpriteBatch(), text, X,Y);
}
示例5: drawText
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
@Override
public void drawText(BitmapFont font, CharSequence text, float X, float Y) {
font.draw(batch, text, X, Y);
}
示例6: drawTextCentered
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
public static void drawTextCentered(BitmapFont font, SpriteBatch batch, String text, float width, float height) {
font.draw(batch, text, width/2, height/2, 0, Align.center, true);
}
示例7: debugRender
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
public void debugRender(ShapeRenderer shapeRenderer, SpriteBatch spriteBatch, BitmapFont font, Camera camera) {
// box
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.BLACK);
for (float x = 0; x < mapWidth; x++) {
for (float y = 0; y < mapHeight; y++) {
shapeRenderer.box(x, y, 0, 1f, 1f, 0f);
}
}
shapeRenderer.end();
// fps
spriteBatch.begin();
font.setColor(Color.RED);
font.draw(spriteBatch, Gdx.graphics.getFramesPerSecond() + "", 0, 15);
font.setColor(Color.WHITE);
// costs + cords
for (int x = 0; x < mapWidth; x++) {
for (int y = 0; y < mapHeight; y++) {
Vector2 point = new Vector2(x, y + 1);
CoordinateUtil.worldToTouch(point, camera);
font.draw(spriteBatch, cost[x][y] + "", point.x, point.y);
// point = new Vector2(x, y);
// CoordinateUtil.worldToTouch(point, camera);
// font.draw(spriteBatch, x + "", point.x, point.y);
//
// point = new Vector2(x + 1, y);
// CoordinateUtil.worldToTouch(point, camera);
// font.draw(spriteBatch, y + "", point.x, point.y);
}
}
spriteBatch.end();
// vector
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.RED);
for (int x = 0; x < mapWidth; x++) {
for (int y = 0; y < mapHeight; y++) {
Vector2 dir = direction[x][y];
dir = dir.cpy().scl(0.5f);
shapeRenderer.circle(x + 0.5f, y + 0.5f, 0.1f, 20);
shapeRenderer.line(x + 0.5f, y + 0.5f, x + dir.x + 0.5f, y + dir.y + 0.5f);
}
}
shapeRenderer.end();
}
示例8: DrawText
import com.badlogic.gdx.graphics.g2d.BitmapFont; //导入方法依赖的package包/类
public void DrawText(SpriteBatch batch, String text, float x, float y)
{
BitmapFont font = skin.getFont("default-font");
font.draw(batch, text, x, y);
}