public GameState(String name, String tmx, StateManager manager) {
this.tmx = tmx;
setManager(manager);
if(name!=null)
this.name = name;
else
this.name = "";
sprites = new ObjectMap<String, Sprite>();
animations = new ObjectMap<String, Animation<String>>();
fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
particle_effects = new ObjectMap<String, ParticleEffectPool>();
pvalues = new Array<String>();
time_scale = 1f;
shaders = new ObjectMap<String, ShaderProgram>();
svalues = new Array<String>();
}
java类com.badlogic.gdx.graphics.g2d.BitmapFont的实例源码
GameState.java 文件源码
项目:KyperBox
阅读 28
收藏 0
点赞 0
评论 0
LoadingScreen.java 文件源码
项目:ProjektGG
阅读 29
收藏 0
点赞 0
评论 0
private void onFinishedLoading() {
BitmapFont main19Font = assetManager.get(MAIN_FONT_19_PATH());
BitmapFont main22Font = assetManager.get(MAIN_FONT_22_PATH());
BitmapFont letter20Font = assetManager.get(LETTER_FONT_20_PATH());
BitmapFont handwritten20Font = assetManager
.get(HANDWRITTEN_FONT_20_PATH());
ObjectMap<String, Object> fontMap = new ObjectMap<String, Object>();
fontMap.put("main-19", main19Font);
fontMap.put("main-22", main22Font);
fontMap.put("letter-20", letter20Font);
fontMap.put("handwritten-20", handwritten20Font);
assetManager.load(SKIN_PATH, Skin.class,
new SkinLoader.SkinParameter(SKIN_TEXTURE_ATLAS_PATH, fontMap));
assetManager.finishLoadingAsset(SKIN_PATH);
// game.setUISkin(assetManager.get(SKIN_PATH));
VisUI.load();
game.setUISkin(VisUI.getSkin());
// Notify loaded screens
game.getScreen("serverBrowser").finishLoading();
game.pushScreen("mainMenu");
}
WorldRenderer.java 文件源码
项目:libgdx-learnlib
阅读 32
收藏 0
点赞 0
评论 0
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);
}
Assets.java 文件源码
项目:libgdx-learnlib
阅读 27
收藏 0
点赞 0
评论 0
public AssetFonts() {
// Create three fonts using libGdx's 15px bitmap font
defaultSmall = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);
defaultNormal = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);
defaultBig = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);
// set font sizes
defaultSmall.getData().setScale(0.75f);
defaultNormal.getData().setScale(1.0f);
defaultBig.getData().setScale(2.0f);
// enable linear texture filtering for smooth fonts
defaultSmall.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
defaultNormal.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
defaultBig.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
}
GameOver.java 文件源码
项目:Flappy-Baranus
阅读 31
收藏 0
点赞 0
评论 0
public GameOver(GameStateManager gsm, int score) {
super(gsm);
this.score = score;
camera.setToOrtho(false, FlappyBaran.WIDTH / 2, FlappyBaran.HEIGHT / 2);
background = new Texture("backgrnd.jpg");
gameover = new Texture("gameover.png");
font = new BitmapFont();
prefs = Gdx.app.getPreferences("FlappyBaran");
if (!prefs.contains("highScore")) {
prefs.putInteger("highScore", 0);
}
prevHighScore = getHighScore();
if (prevHighScore < this.score) {
setHighScore(this.score);
highscore = this.score;
} else {
highscore = prevHighScore;
}
}
Hud.java 文件源码
项目:DarkDay
阅读 23
收藏 0
点赞 0
评论 0
public Hud(SpriteBatch sb) {
countKill = 0;
viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());
stage = new Stage(viewport, sb);
Table table = new Table();
table.setFillParent(true);
table.top();
countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
table.add(countKillLabel).expandX().padTop(10);
table.add().expandX();
table.add().expandX();
table.add().expandX();
stage.addActor(table);
}
FilledIconBar.java 文件源码
项目:SpaceChaos
阅读 21
收藏 0
点赞 0
评论 0
public FilledIconBar(Texture heartTexture, BitmapFont font) {
super();
this.font = font;
// add heart icon
this.heartImageWidget = new ImageWidget(heartTexture);
this.heartImageWidget.setPosition(0, 0);
this.addWidget(this.heartImageWidget);
// add health widget
this.filledBar = new FilledBar(this.font);
this.filledBar.setPosition(40, 6);
this.filledBar.setDimension(80, 20);
this.addWidget(this.filledBar);
}
GameState.java 文件源码
项目:KyperBox
阅读 24
收藏 0
点赞 0
评论 0
private void loadFonts(TiledMap data, String atlasname) {
MapObjects objects = data.getLayers().get("preload").getObjects();
String ffcheck = "Font";
for (MapObject o : objects) {
String name = o.getName();
BitmapFont font = null;
MapProperties properties = o.getProperties();
String type = properties.get("type", String.class);
String fontfile = properties.get("font_file", String.class);
if (fontfile != null && type != null && type.equals(ffcheck)) {
boolean markup = properties.get("markup", false, boolean.class);
game.loadFont(fontfile, atlasname);
game.getAssetManager().finishLoading();
font = game.getFont(fontfile);
fonts.put(name, font);
font.getData().markupEnabled = markup;
}
}
}
Assets.java 文件源码
项目:ExamensArbeteTD
阅读 22
收藏 0
点赞 0
评论 0
private static BitmapFont createFont(int fontSize , Fonts type) {
FileHandle fontFile = null;
switch(type){
case HEMI_HEAD: fontFile = Gdx.files.internal("fonts/HEMIHEAD.TTF"); break;
case VERA: fontFile = Gdx.files.internal("fonts/Vera.ttf"); break;
case VERA_BD: fontFile = Gdx.files.internal("fonts/VeraBd.ttf"); break;
default:
break;
}
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = fontSize;
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
return font;
}
BitmapFontFactory.java 文件源码
项目:SpaceChaos
阅读 32
收藏 0
点赞 0
评论 0
public static BitmapFont createFont(String fontPath, int size, Color color, Color borderColor, int borderWidth) {
// load font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontPath));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
// https://github.com/libgdx/libgdx/wiki/Gdx-freetype
parameter.size = size;
parameter.borderColor = borderColor;
parameter.borderWidth = borderWidth;
parameter.color = color;
BitmapFont font48 = generator.generateFont(parameter);
generator.dispose();
return font48;
}
SplashScreen.java 文件源码
项目:gdx-splash
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void create() {
VisUI.load();
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
img = new Texture("splash.png");
font = new BitmapFont(Gdx.files.internal("font/openSans.fnt"), Gdx.files.internal("font/openSans.png"), false, true);
window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
// start loading
loadingTask = new LoadingTask();
try {
loadingTask.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
MenuScreen.java 文件源码
项目:EarthInvadersGDX
阅读 31
收藏 0
点赞 0
评论 0
public MenuScreen() {
camera = new OrthographicCamera();
viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
viewport.apply();
camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
camera.update();
betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
betaText.getData().setScale(0.35f);
logo = new Sprite(new Texture("logo.png"));
Random r = new Random();
background = new Particle[r.nextInt(55 - 45) + 45];
for (int i = 0; i < background.length; i++) {
int size = r.nextInt(4) + 1;
int x = r.nextInt(Game.WIDTH);
int y = r.nextInt(Game.HEIGHT);
background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size);
}
musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
play = new CenteredButton(500, "buttons/play.png");
music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
music.setScale(4f);
}
LoginScreen.java 文件源码
项目:CursedEcho
阅读 36
收藏 0
点赞 0
评论 0
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
GameUtils.getGame().assets.put("Players/player.png", Texture.class);
GameUtils.getGame().assets.put("World/grass.png", Texture.class);
GameUtils.getGame().assets.put("Fonts/HUDFont.fnt", BitmapFont.class);
switch(Gdx.app.getType()) {
case Android:
GameUtils.getGame().assets.put("Controls/touchBackground.png", Texture.class);
GameUtils.getGame().assets.put("Controls/touchKnob.png", Texture.class);
break;
default:
break;
}
}
TestCryptTextureAtlas.java 文件源码
项目:libgdx-crypt-texture
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
font.setColor(0, 0, 1, 1);
// Origin
TextureAtlas originTextureAtlas = new TextureAtlas(ORIGIN_PATH + "/test.atlas");
Skin originSkin = new Skin(originTextureAtlas);
originTextureRegion = originSkin.getRegion("badlogic");
// Encrypt
SimpleXorCryptoEncryptor.process("123", "atlas", "encryptedAtlas");
// Decrypt
CryptTextureAtlas cryptTextureAtlas = new CryptTextureAtlas(crypto, ENCRYPTED_PATH + "/test.atlas");
Skin skin = new Skin(cryptTextureAtlas);
decryptTextureRegion = skin.getRegion("badlogic");
}
MessageWindow.java 文件源码
项目:Tower-Defense-Galaxy
阅读 34
收藏 0
点赞 0
评论 0
public MessageWindow(String message, BitmapFont font, float width, float height) {
setTouchable(Touchable.enabled);
setBounds(width / 2 - width / 4, height / 2 - height / 10, width / 2, height / 5);
texture = new Texture("theme/basic/ui/Window.png");
this.message = message;
table = new Table();
table.setSize(getWidth(), getHeight());
table.align(Align.center | Align.top);
table.setPosition(getX(), getY());
Label label = new Label(message, new Label.LabelStyle(font, Color.BLACK));
label.setWrap(true);
label.setFontScale(0.7f);
Label label2 = new Label("Tap to continue", new Label.LabelStyle(font, Color.BLACK));
label2.setFontScale(0.6f);
table.add(label).width(getWidth());
table.row();
table.add(label2).width(getWidth()).expandY();
table.pad(0, 30, 0, 30);
}
GameOverState.java 文件源码
项目:StarshipFighters
阅读 31
收藏 0
点赞 0
评论 0
@Override
public void init() {
// Start Sound and Music
musicManager = gsm.getGame().getMusicManager();
soundManager = gsm.getGame().getSoundManager();
soundManager.addSound(selectSound, choiceOptionName);
// Start Bitmap Font
bitmapFont = new BitmapFont();
//bitmapFont.getData().setScale(3);
// Spritebatch start
spriteBatch = game.getSpriteBatch();
// Current Option Start
currentOption = 0;
// Add Sound effect
soundManager.addSound(selectSound, choiceOptionName);
}
SkinLoader.java 文件源码
项目:Klooni1010
阅读 21
收藏 0
点赞 0
评论 0
static Skin loadSkin() {
String folder = "ui/x" + bestMultiplier + "/";
// Base skin
Skin skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
// Nine patches
final int border = (int)(28 * bestMultiplier);
skin.add("button_up", new NinePatch(new Texture(
Gdx.files.internal(folder + "button_up.png")), border, border, border, border));
skin.add("button_down", new NinePatch(new Texture(
Gdx.files.internal(folder + "button_down.png")), border, border, border, border));
for (String id : ids) {
skin.add(id + "_texture", new Texture(Gdx.files.internal(folder + id + ".png")));
}
folder = "font/x" + bestMultiplier + "/";
skin.add("font", new BitmapFont(Gdx.files.internal(folder + "geosans-light64.fnt")));
skin.add("font_small", new BitmapFont(Gdx.files.internal(folder + "geosans-light32.fnt")));
skin.add("font_bonus", new BitmapFont(Gdx.files.internal(folder + "the-next-font.fnt")));
return skin;
}
DeathScreen.java 文件源码
项目:Polymorph
阅读 27
收藏 0
点赞 0
评论 0
public DeathScreen(Polymorph polymorph,int playerscore) {
AssetManager assetManager = polymorph.getAssetManager();
TextureAtlas textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
this.polymorph = polymorph;
score=playerscore;
DeathScreenMusic = assetManager.get(Polymorph.MAIN_MENU_MUSIC_PATH);
DeathScreenMusic.setLooping(true);
background = textureAtlas.findRegion("mainmenu"); //TODO make a unique background for the death screen
screenSize = new Dimension(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera = new OrthographicCamera();
camera.setToOrtho(false, screenSize.width, screenSize.height); //change this
batch=new SpriteBatch();
batch.setProjectionMatrix(camera.combined);
stage = new Stage();
stage.clear();
font = new BitmapFont(false);
textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
initButtons(score,textureAtlas);
Gdx.input.setInputProcessor(stage);
}
LoadingScreen.java 文件源码
项目:ProjektGG
阅读 27
收藏 0
点赞 0
评论 0
public final AssetDescriptor<BitmapFont> MAIN_FONT_19_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
font.fontParameters.size = 19;
return new AssetDescriptor<BitmapFont>("mainFont19.ttf",
BitmapFont.class, font);
}
LoadingScreen.java 文件源码
项目:ProjektGG
阅读 33
收藏 0
点赞 0
评论 0
public final AssetDescriptor<BitmapFont> MAIN_FONT_22_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/AlemdraSC/AlmendraSC-Regular.ttf";
font.fontParameters.size = 22;
return new AssetDescriptor<BitmapFont>("mainFont22.ttf",
BitmapFont.class, font);
}
LoadingScreen.java 文件源码
项目:ProjektGG
阅读 32
收藏 0
点赞 0
评论 0
public final AssetDescriptor<BitmapFont> HANDWRITTEN_FONT_20_PATH() {
FreeTypeFontLoaderParameter font = new FreeTypeFontLoaderParameter();
font.fontFileName = "fonts/ReenieBeanie/ReenieBeanie.ttf";
font.fontParameters.size = 20;
return new AssetDescriptor<BitmapFont>("handwrittenFont20.ttf",
BitmapFont.class, font);
}
PCMenu.java 文件源码
项目:ggvm
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void setDependencies(String fontFileName, String fontBitmapFileName, GGVm ggvm, InputProcessorBase inputProcessor, SoundtrackManager soundtrackManager) {
FileHandle fontFileHandle = Gdx.files.internal(fontFileName);
FileHandle fontBitmapFileHandle = Gdx.files.internal(fontBitmapFileName);
bitmapFont = new BitmapFont(fontFileHandle, fontBitmapFileHandle, false);
topLevelMenu = new TopLevelMenu();
promptInputMenu = new PromptInputMenu();
menu = topLevelMenu;
this.ggvm = ggvm;
this.inputProcessor = (KeyboardInputProcessor) inputProcessor;
this.soundtrackManager = soundtrackManager;
}
Hexpert.java 文件源码
项目:Hexpert
阅读 32
收藏 0
点赞 0
评论 0
public BitmapFont getFont() {
if (font == null) {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/VCROSDMono.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 35;
parameter.borderWidth = 1;
parameter.color = Color.BLACK;
font = generator.generateFont(parameter);
generator.dispose();
}
return font;
}
TradeWindow.java 文件源码
项目:Catan
阅读 25
收藏 0
点赞 0
评论 0
private BitmapFont getFont() {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/DroidSans.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 20;
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
return font;
}
PlayState.java 文件源码
项目:FlappyChapa
阅读 29
收藏 0
点赞 0
评论 0
public PlayState(GameStateManager gsm) {
super(gsm);
score = 0;
chapa = new Chapa(50, 300);
camera.setToOrtho(false, FlappyChapa.WIDTH / 2, FlappyChapa.HEIGHT / 2);
Texture texture = new Texture("bg.png");
backGround = new org.academiadecodigo.bootcamp.sprites.Background(camera);
backGround.start();
ground = new Texture("ground.png");
/*table = new Table();
table.setPosition(camera.position.x,camera.position.y);
//table.setBounds(camera.position.x,camera.position.y,camera.viewportWidth,camera.viewportHeight/10);
table.setFillParent(true);*/
scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
scoreLabel.setPosition(camera.position.x,0);
startTime = TimeUtils.nanoTime();
anto = new Anto(camera);
// groundPos1 = new Vector2(camera.position.x - camera.viewportWidth / 2, GROUND_Y_OFFSET);
// groundPos2 = new Vector2((camera.position.x - camera.viewportWidth / 2) + ground.getWidth(), GROUND_Y_OFFSET);
tubes = new Array<Tube>();
for (int i = 0; i < TUBE_COUNT; i++) {
tubes.add(new Tube(i * (TUBE_SPACING + Tube.TUBE_WIDTH)));
}
music = Gdx.audio.newMusic(Gdx.files.internal("bigSmoke_justAudio.mp3"));
music.setLooping(true);
music.setVolume(0.5f);
music.play();
}
AssetDoctor.java 文件源码
项目:Ponytron
阅读 19
收藏 0
点赞 0
评论 0
public static BitmapFont getFont(String id, String file, Color color, int size) {
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = size;
parameter.color = color;
FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal(file));
BitmapFont font = gen.generateFont(parameter);
font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
return font;
}
LoadingScreen.java 文件源码
项目:Parasites-of-HellSpace
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void show()
{
batch = new SpriteBatch();
splashScreen = new Texture("loadscreen.png");
loaded = false;
font = new BitmapFont(Gdx.files.internal("sans.fnt"), false);
AssetLoader.create();
}
TextUtil.java 文件源码
项目:drc-sim-client
阅读 30
收藏 0
点赞 0
评论 0
public static BitmapFont generateScaledFont(float scale) {
int size = (int) (50f * Gdx.graphics.getHeight() * scale / 720f);
if (fonts.containsKey(size))
return fonts.get(size);
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font/coolvetica.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = size;
FreeTypeFontGenerator.setMaxTextureSize(FreeTypeFontGenerator.NO_MAXIMUM);
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
fonts.put(size, font);
return font;
}
BitmapFontFactory.java 文件源码
项目:SpaceChaos
阅读 27
收藏 0
点赞 0
评论 0
public static BitmapFont createFont(String fontPath, int size, Color color) {
// load font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontPath));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = size;
parameter.color = color;
BitmapFont font48 = generator.generateFont(parameter);
generator.dispose();
return font48;
}
InputSettingsScreen.java 文件源码
项目:arcadelegends-gg
阅读 26
收藏 0
点赞 0
评论 0
private void initInputRows(BitmapFont font, TextureRegion backgroundTexture)
{
for (int i = 0; i < keys.length; i++) {
Label lbKey = new Label(keys[i].getKeyName().substring(0, 1).toUpperCase() + keys[i].getKeyName().substring(1), skin);
lbKey.setAlignment(Align.center);
keyMap.put(keys[i].getKeyName(), i);
TextButton btKey = new TextButton(Input.Keys.toString(IInputConfig.InputKeys.getFromKey(keys[i], AL.getInputConfig())), skin);
btKey.setText(btKey.getText().toString().toUpperCase());
btKey.center();
btKey.setName(keys[i].getKeyName());
btKey.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
showDialog(font, backgroundTexture, btKey.getName(), btKey);
}
});
inputTable.add(lbKey).pad(10).fill();
inputTable.add(btKey).pad(10).fill();
inputTable.row();
}
scrollPane = new ScrollPane(inputTable, skin);
scrollPane.setSize(500, 900);
scrollPane.setPosition(1920 / 2 - 250, 1080 / 2 - 400);
stage.addActor(scrollPane);
}