List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFont BitmapFont
public BitmapFont(FileHandle fontFile, boolean flip)
From source file:at.juggle.games.memory.AssetManager.java
License:Apache License
public AssetManager(GameOptions options) { this.options = options; Preferences preferences = Gdx.app.getPreferences("memory_free_hd.prefs"); if (preferences.contains("soundOn")) { options.soundOn = preferences.getBoolean("soundOn"); }/*from ww w . ja va2 s . c o m*/ font = new BitmapFont(getFileHandle("berlin_64.fnt"), false); smallFont = new BitmapFont(getFileHandle("berlin_42.fnt"), false); card = new Texture(getFileHandle("card-front.png")); cardBack = new Texture(getFileHandle("card-back.png")); cardBackMark = new Texture(getFileHandle("card-back-mark.png")); check = new Texture(getFileHandle("Check_32x32.png")); positive = new Texture(getFileHandle("Positive_256x256.png")); grey = new Texture(getFileHandle("grey.png")); background = new Texture(getFileHandle("background.jpg")); gradientTop = new Texture(getFileHandle("gradient_oben.png")); gradientBottom = new Texture(getFileHandle("gradient_unten.png")); if (GameOptions.isFreeVersion) { logo = new Texture(getFileHandle("Logo.png")); } else { logo = new Texture(getFileHandle("Logo_donated.png")); } cardBack.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); cardBackMark.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logo.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); Texture vehiclesTexture = new Texture(getFileHandle("vehicles.png")); vehiclesTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); TextureRegion[][] veh = TextureRegion.split(vehiclesTexture, 256, 256); icons = new TextureRegion[24]; icons[0] = new TextureRegion(loadTexture("animals/Butterfly_128x128.png")); icons[1] = new TextureRegion(loadTexture("animals/Dolphin_128x128.png")); icons[2] = new TextureRegion(loadTexture("animals/Elephant_128x128.png")); icons[3] = new TextureRegion(loadTexture("animals/Hippopotamus_128x128.png")); icons[4] = new TextureRegion(loadTexture("animals/Panda_128x128.png")); icons[5] = new TextureRegion(loadTexture("animals/Turtle_128x128.png")); icons[6] = new TextureRegion(loadTexture("vacation/surfboard_256x256.png")); icons[7] = new TextureRegion(loadTexture("vacation/umbrella_256x256.png")); int count = 0; for (int i = 0; i < veh.length; i++) { TextureRegion[] textureRegions = veh[i]; for (int j = 0; j < textureRegions.length; j++) { icons[8 + count] = textureRegions[j]; count++; } } // Particle effects fireworks = new ParticleEffect(); fireworks.load(getFileHandle("fireworks"), getFileHandle("")); // sounds sndFlipCard = Gdx.audio.newSound(getFileHandle("flipcard.ogg")); sndCheer = Gdx.audio.newSound(getFileHandle("drums.ogg")); sndDing = Gdx.audio.newSound(getFileHandle("ding.ogg")); }
From source file:com.android.ringfly.common.Assets.java
License:Apache License
private static void loadFonts() { huaWenXiHeiFont = new BitmapFont(Gdx.files.internal("data/fonts/32/huiwenxihei32.fnt"), false); // huaWenXiHeiFont.setScale(1.0f / pixelDensity); }
From source file:com.badlogic.gdx.tests.BulletTestCollection.java
License:Apache License
@Override public void create() { if (app == null) { app = Gdx.app;//ww w.ja va 2s. c o m tests[testIndex].create(); } cameraController = new CameraInputController(tests[testIndex].camera); cameraController.activateKey = Keys.CONTROL_LEFT; cameraController.autoUpdate = false; cameraController.forwardTarget = false; cameraController.translateTarget = false; Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this))); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); hud = new Stage(); hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE))); fpsLabel.setPosition(0, 0); hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE))); titleLabel.setY(hud.getHeight() - titleLabel.getHeight()); hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE))); instructLabel.setY(titleLabel.getY() - instructLabel.getHeight()); instructLabel.setAlignment(Align.top | Align.left); instructLabel.setText(tests[testIndex].instructions); }
From source file:com.badlogic.gdx.tests.gwt.GwtTestWrapper.java
License:Apache License
@Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); Gdx.app.log("GdxTestGwt", "Setting up for " + tests.length + " tests."); ui = new Stage(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); container = new Table(); ui.addActor(container);/*from ww w. ja v a2 s . c o m*/ container.debug(); Table table = new Table(); ScrollPane scroll = new ScrollPane(table); container.add(scroll).expand().fill(); table.pad(10).defaults().expandX().space(4); for (final Instancer instancer : tests) { table.row(); TextButton button = new TextButton(instancer.instance().getClass().getName(), skin); button.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((InputWrapper) Gdx.input).multiplexer.removeProcessor(ui); test = instancer.instance(); Gdx.app.log("GdxTestGwt", "Clicked on " + test.getClass().getName()); test.create(); test.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } }); table.add(button).expandX().fillX(); } container.row(); container.add( new Label("Click on a test to start it, press ESC to close it.", new LabelStyle(font, Color.WHITE))) .pad(5, 5, 5, 5); Gdx.input = new InputWrapper(Gdx.input) { @Override public boolean keyUp(int keycode) { if (keycode == Keys.ESCAPE) { if (test != null) { Gdx.app.log("GdxTestGwt", "Exiting current test."); dispose = true; } } return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (screenX < Gdx.graphics.getWidth() / 10.0 && screenY < Gdx.graphics.getHeight() / 10.0) { if (test != null) { dispose = true; } } return false; } }; ((InputWrapper) Gdx.input).multiplexer.addProcessor(ui); Gdx.app.log("GdxTestGwt", "Test picker UI setup complete."); }
From source file:com.badlydrawngames.veryangryrobots.Assets.java
License:Apache License
private static void loadFonts() { String fontDir = "data/fonts/" + (int) pixelDensity + "/"; scoreFont = new BitmapFont(Gdx.files.internal(fontDir + SCORE_FONT), false); textFont = new BitmapFont(Gdx.files.internal(fontDir + TEXT_FONT), false); flyupFont = new BitmapFont(Gdx.files.internal(fontDir + FLYUP_FONT), false); scoreFont.setScale(1.0f / pixelDensity); textFont.setScale(1.0f / pixelDensity); flyupFont.setScale(1.0f / pixelDensity); }
From source file:com.bossletsplays.rr.gfx.Font.java
License:Apache License
public Font(String file, boolean flip) { String name = file + ".fnt"; try {/*w ww . j a v a2 s .c om*/ LogHelper.track("Attempting to load font file: " + name); this.font = new BitmapFont(Files.internal("fonts/" + name), flip); LogHelper.info("Font <" + file + "> loaded"); } catch (Exception e) { LogHelper.warn("Font <" + file + "> not found"); this.font = new BitmapFont(Files.internal("fonts/terminal.fnt"), flip); } }
From source file:com.cookbook.samples.client.GwtSampleWrapper.java
License:Apache License
@Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); Gdx.app.log("GdxSampleGwt", "Setting up for " + tests.length + " tests."); ui = new Stage(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); container = new Table(); ui.addActor(container);// w w w . j ava2s . com container.debug(); Table table = new Table(); ScrollPane scroll = new ScrollPane(table); container.add(scroll).expand().fill(); table.pad(10).defaults().expandX().space(4); for (final Instancer instancer : tests) { table.row(); TextButton button = new TextButton(instancer.instance().getClass().getName(), skin); button.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((InputWrapper) Gdx.input).multiplexer.removeProcessor(ui); test = instancer.instance(); Gdx.app.log("GdxSampleGwt", "Clicked on " + test.getClass().getName()); test.create(); test.setPlatformResolver(new WebResolver()); test.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } }); table.add(button).expandX().fillX(); } container.row(); container.add( new Label("Click on a test to start it, press ESC to close it.", new LabelStyle(font, Color.WHITE))) .pad(5, 5, 5, 5); Gdx.input = new InputWrapper(Gdx.input) { @Override public boolean keyUp(int keycode) { if (keycode == Keys.ESCAPE) { if (test != null) { Gdx.app.log("GdxSampleGwt", "Exiting current test."); dispose = true; } } return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (screenX < Gdx.graphics.getWidth() / 10.0 && screenY < Gdx.graphics.getHeight() / 10.0) { if (test != null) { dispose = true; } } return false; } }; ((InputWrapper) Gdx.input).multiplexer.addProcessor(ui); Gdx.app.log("GdxSampleGwt", "Test picker UI setup complete."); }
From source file:com.digitale.mygdxgame.SplashRenderer.java
License:Open Source License
public SplashRenderer(Application app) { font = new BitmapFont(Gdx.files.internal("data/default.fnt"), false); try {/* www .j a va 2 s .co m*/ spriteBatch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); InputStream in = Gdx.files.internal("data/ship02.obj").read(); shipMesh = ObjLoader.loadObj(in, true); in.close(); in = Gdx.files.internal("data/jet.obj").read(); jetMesh = ObjLoader.loadObj(in, true); in.close(); in = Gdx.files.internal("data/sun.obj").read(); sunMesh = ObjLoader.loadObj(in, true); in.close(); in = Gdx.files.internal("data/planet.obj").read(); planetMesh = ObjLoader.loadObj(in, true); in.close(); in = Gdx.files.internal("data/planet02.obj").read(); planetMesh02 = ObjLoader.loadObj(in, true); in.close(); in = Gdx.files.internal("data/shot.obj").read(); ObjLoader.loadObj(in, false); in.close(); //note use of tru to flip texture V co-ords for max OBJ files in = Gdx.files.internal("data/sky.obj").read(); skyMesh = ObjLoader.loadObj(in, true); in.close(); progressBarTexture = new Texture(Gdx.files.internal("data/progbar.png"), Format.RGB565, true); progressBarTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.jmolina.orb.widgets.debug.DebugTime.java
License:Open Source License
public DebugTime(AssetManager am) { spriteBatch = new SpriteBatch(); Label.LabelStyle style = new Label.LabelStyle(); style.fontColor = new Color(Var.COLOR_RED); style.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_BOLD_45), am.getGameAtlas().findRegion(Atlas.FONT_ROBOTO_BOLD_45)); frametime = new Label("", style); frametime.setPosition(Utils.cell(1), Utils.cell(1)); }
From source file:com.jmolina.orb.widgets.game.Timer.java
License:Open Source License
/** * Constructor/*from w w w.j ava 2s .c o m*/ * * @param am AssetManager */ public Timer(AssetManager am) { super(am); Label.LabelStyle style = new Label.LabelStyle(); style.fontColor = new Color(Var.COLOR_WHITE); style.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_BOLD_90), findRegion(Atlas.FONT_ROBOTO_BOLD_90)); label = new Label("", style); label.setTouchable(Touchable.disabled); label.setPosition(0, 0); label.setHeight(Utils.cell(1.5f)); label.setWidth(Utils.cell(6)); label.setAlignment(Align.center); addActor(label); setTransform(false); setHeight(Utils.cell(1.5f)); reset(); }