com.badlogic.gdx.graphics.g2d.BitmapFont Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.g2d.BitmapFont.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlopsyScreen.java From flopsydroid with Apache License 2.0 | 6 votes |
public FlopsyScreen(FlopsyDroidGame game, OnGlobalListener listener) { mStage = new Stage(); mGlobalListener = listener; game.getAssetManager().load("flopsy.sprites", TextureAtlas.class); game.getAssetManager().finishLoading(); mTextureAtlas = game.getAssetManager().get("flopsy.sprites", TextureAtlas.class); mLabelStyle = new Label.LabelStyle(); mLabelStyle.font = new BitmapFont(Gdx.files.internal("flappyfont.fnt"), Gdx.files.internal("flappyfont.png"), false); mStage.addListener(new EventListener() { @Override public boolean handle(Event event) { if(event.getTarget().equals(mAndy)) { mGround.onDroidCollision(); return true; } return false; } }); }
Example #2
Source File: MainListener.java From skin-composer with MIT License | 6 votes |
@Override public void stylePropertyChanged(StyleProperty styleProperty, Actor styleActor) { if (styleProperty.type == Drawable.class) { dialogFactory.showDialogDrawables(styleProperty, dialogListener); } else if (styleProperty.type == Color.class) { dialogFactory.showDialogColors(styleProperty, dialogListener); } else if (styleProperty.type == BitmapFont.class) { dialogFactory.showDialogFonts(styleProperty, dialogListener); } else if (styleProperty.type == Float.TYPE) { main.getUndoableManager().addUndoable(new UndoableManager.DoubleUndoable(main, styleProperty, ((Spinner) styleActor).getValue()), false); } else if (styleProperty.type == ScrollPaneStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } else if (styleProperty.type == LabelStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } else if (styleProperty.type == ListStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } }
Example #3
Source File: IciclesScreen.java From ud405 with MIT License | 6 votes |
@Override public void show() { iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); hudViewport = new ScreenViewport(); batch = new SpriteBatch(); font = new BitmapFont(); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); player = new Player(iciclesViewport); icicles = new Icicles(iciclesViewport, difficulty); Gdx.input.setInputProcessor(this); topScore = 0; }
Example #4
Source File: IciclesScreen.java From ud405 with MIT License | 6 votes |
@Override public void show() { iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); // TODO: Initialize the HUD viewport hudViewport = new ScreenViewport(); // TODO: Initialize the SpriteBatch batch = new SpriteBatch(); // TODO: Initialize the BitmapFont font = new BitmapFont(); // TODO: Give the font a linear TextureFilter font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); player = new Player(iciclesViewport); icicles = new Icicles(iciclesViewport); // TODO: Set top score to zero topScore = 0; }
Example #5
Source File: SkinLoader.java From Klooni1010 with GNU General Public License v3.0 | 6 votes |
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; }
Example #6
Source File: FontUtilTest.java From cocos-ui-libgdx with Apache License 2.0 | 6 votes |
@Test @NeedGL public void shouldUnableToGenerateBitmapIfCharNotInTTF() throws Exception { FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf"); String text = "มันเป็นการทดสอบ"; BitmapFont bitmapFont = FontUtil.createFont(defaultFont, text, 14); assertThat(bitmapFont, not(nullValue())); for (char c : text.toCharArray()) { BitmapFont.Glyph glyph = bitmapFont.getData().getGlyph(c); try { assertThat(glyph, is(nullValue())); } catch (AssertionError ignored) { //Different behaviour for 1.7.0 assertThat(glyph.id, is(127)); } } }
Example #7
Source File: HighlightTextArea.java From vis-ui with Apache License 2.0 | 6 votes |
@Override protected void drawText (Batch batch, BitmapFont font, float x, float y) { maxAreaHeight = 0; float offsetY = 0; for (int i = firstLineShowing * 2; i < (firstLineShowing + linesShowing) * 2 && i < linesBreak.size; i += 2) { for (Chunk chunk : renderChunks) { if (chunk.lineIndex == i) { font.setColor(chunk.color); font.draw(batch, chunk.text, x + chunk.offsetX, y + offsetY); } } offsetY -= font.getLineHeight(); maxAreaHeight += font.getLineHeight(); } maxAreaHeight += 30; }
Example #8
Source File: DesktopPlatformSupport.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override public void resetGenerators() { if (fonts != null) { for (FreeTypeFontGenerator generator : fonts.keySet()) { for (BitmapFont f : fonts.get(generator).values()) { f.dispose(); } fonts.get(generator).clear(); generator.dispose(); } fonts.clear(); if (packer != null) { for (PixmapPacker.Page p : packer.getPages()) { p.getTexture().dispose(); } packer.dispose(); } fonts = null; } setupFontGenerators(pageSize, systemfont); }
Example #9
Source File: DesktopPlatformSupport.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public BitmapFont getFont(int size, String text) { FreeTypeFontGenerator generator = getGeneratorForString(text); if (generator == null){ return null; } if (!fonts.get(generator).containsKey(size)) { FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameters.size = size; parameters.flip = true; parameters.borderWidth = parameters.size / 10f; parameters.renderCount = 3; parameters.hinting = FreeTypeFontGenerator.Hinting.None; parameters.spaceX = -(int) parameters.borderWidth; parameters.incremental = true; if (generator == basicFontGenerator){ //if we're using latin/cyrillic, we can safely pre-generate some common letters //(we define common as >4% frequency in english) parameters.characters = "�etaoinshrdl"; } else { parameters.characters = "�"; } parameters.packer = packer; try { BitmapFont font = generator.generateFont(parameters); font.getData().missingGlyph = font.getData().getGlyph('�'); fonts.get(generator).put(size, font); } catch ( Exception e ){ Game.reportException(e); return null; } } return fonts.get(generator).get(size); }
Example #10
Source File: TabbedPane.java From gdx-ai with Apache License 2.0 | 5 votes |
public TabbedPaneStyle (Drawable titleBegin, Drawable titleEnd, Drawable bodyBackground, Drawable titleButtonSelected, Drawable titleButtonUnselected, BitmapFont font) { this.titleBegin = titleBegin; this.titleEnd = titleEnd; this.bodyBackground = bodyBackground; this.titleButtonSelected = titleButtonSelected; this.titleButtonUnselected = titleButtonUnselected; this.font = font; }
Example #11
Source File: FPSCounterScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { // TODO: Initialize the SpriteBatch batch = new SpriteBatch(); // TODO: Initialize the BitmapFont font = new BitmapFont(); font.getData().setScale(2); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); // TODO: Initialize the ScreenViewport viewport = new ScreenViewport(); }
Example #12
Source File: StatLabel.java From riiablo with Apache License 2.0 | 5 votes |
private static BitmapFont getFont(int len) { if (len > 6) { return Riiablo.fonts.ReallyTheLastSucker; } else if (len > 3) { return Riiablo.fonts.font8; } else { return Riiablo.fonts.font16; } }
Example #13
Source File: ScreenGameMap.java From RuinsOfRevenge with MIT License | 5 votes |
private Stack<String> splitIntoLinesRec(Stack<String> list, String line, BitmapFont font, float width) { int visible = font.computeVisibleGlyphs(line, 0, line.length(), width); if (line.length() > visible) { String head = line.substring(0, visible-1); String rest = line.substring(visible, line.length()-1); list.push(head); return splitIntoLinesRec(list, rest, font, width); } else { list.push(line); return list; } }
Example #14
Source File: MyScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { batch = new SpriteBatch(); font = new BitmapFont(); font.getData().setScale(2); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); viewport = new ScreenViewport(); }
Example #15
Source File: Score.java From martianrun with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (getScore() == 0) { return; } font.drawWrapped(batch, String.format("%d", getScore()), bounds.x, bounds.y, bounds.width, BitmapFont.HAlignment.RIGHT); }
Example #16
Source File: ResourceManager.java From TerraLegion with MIT License | 5 votes |
public BitmapFont getFont(String id, String file, Color color, int size) { FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal(file)); BitmapFont font = gen.generateFont(size); font.setColor(color); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); return font; }
Example #17
Source File: WrathCardIconPatch.java From jorbs-spire-mod with MIT License | 5 votes |
@SpirePostfixPatch public static void Postfix(AbstractCard card, SpriteBatch sb) { int wrathCount = WrathField.wrathEffectCount.get(card); boolean darken = ReflectionUtils.getPrivateField(card, AbstractCard.class, "darken"); if (wrathCount == 0 || darken || card.isLocked || !card.isSeen) { return; } Color renderColor = ReflectionUtils.getPrivateField(card, AbstractCard.class, "renderColor"); RenderUtils.renderAtlasRegionCenteredAt(sb, wrathIconOverlayImg, card.current_x, card.current_y, card.drawScale * Settings.scale, renderColor, card.angle); WRATH_TEXT_COLOR.a = card.transparency; String text = Integer.toString(wrathCount); BitmapFont font = FontHelper.cardEnergyFont_L; font.getData().setScale(card.drawScale); FontHelper.renderRotatedText(sb, font, text, card.current_x, card.current_y, WRATH_TEXT_OFFSET_X * card.drawScale * Settings.scale, WRATH_TEXT_OFFSET_Y * card.drawScale * Settings.scale, card.angle, false, WRATH_TEXT_COLOR); }
Example #18
Source File: ConnectTheDots.java From ud405 with MIT License | 5 votes |
@Override public void create() { spriteBatch = new SpriteBatch(); bitmapFont = new BitmapFont(); floatDots = vector2ArrayToFloatArray(dots); shapeRenderer = new ShapeRenderer(); }
Example #19
Source File: CharacterPanel.java From riiablo with Apache License 2.0 | 5 votes |
private BitmapFont getFont(int length) { if (length > 6) { return Riiablo.fonts.ReallyTheLastSucker; } else if (length > 3) { return Riiablo.fonts.font8; } else { return Riiablo.fonts.font16; } }
Example #20
Source File: TextButton.java From riiablo with Apache License 2.0 | 5 votes |
public TextButtonStyle (Drawable up, Drawable down, Drawable checked, BitmapFont font) { super(up, down, checked); unpressedOffsetY = -2; pressedOffsetX = -2; pressedOffsetY = unpressedOffsetY + pressedOffsetX; checkedOffsetX = unpressedOffsetX; checkedOffsetY = unpressedOffsetY; this.font = font; fontColor = Color.BLACK; }
Example #21
Source File: Settings.java From libgdx-demo-pax-britannica with MIT License | 5 votes |
@Override public void show() { GameInstance.getInstance().resetGame(); backgroundFX = new BackgroundFXRenderer(); blackFade = Resources.getInstance().blackFade; back = Resources.getInstance().back; back.setPosition(20, 010); back.setColor(1,1,1,0.5f); collisionBack.set(new Vector3(back.getVertices()[0], back.getVertices()[1], -10),new Vector3(back.getVertices()[10], back.getVertices()[11], 10)); collisionDiffEasy.set(new Vector3(90, 330,-10),new Vector3(190, 360, 10)); collisionDiffMedium.set(new Vector3(240, 330,-10),new Vector3(340, 360, 10)); collisionDiffHard.set(new Vector3(400, 330,-10),new Vector3(500, 360, 10)); collisionFacHealthLow.set(new Vector3(90, 230,-10),new Vector3(190, 260, 10)); collisionFacHealthMedium.set(new Vector3(240, 230,-10),new Vector3(340, 260, 10)); collisionFacHealthHigh.set(new Vector3(400, 230,-10),new Vector3(500, 260, 10)); collisionAntiAliasOff.set(new Vector3(90, 130,-10),new Vector3(190, 160, 10)); collisionAntiAliasOn.set(new Vector3(240, 130,-10),new Vector3(340, 160, 10)); checkboxOn = Resources.getInstance().checkboxOn; checkboxOff = Resources.getInstance().checkboxOff; titleBatch = new SpriteBatch(); titleBatch.getProjectionMatrix().setToOrtho2D(0, 0, 800, 480); fadeBatch = new SpriteBatch(); fadeBatch.getProjectionMatrix().setToOrtho2D(0, 0, 2, 2); font = new BitmapFont(); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); }
Example #22
Source File: FluidSimulatorGeneric.java From fluid-simulator-v2 with Apache License 2.0 | 5 votes |
public FluidSimulatorGeneric(FluidSimulatorStarter fluidSimulatorStarter) { this.game = fluidSimulatorStarter; // LibGDX single batches cannot have a size more than 5460 batch = new SpriteBatch(IS_DESKTOP ? 5460 : ANDROID_SIZE); font = new BitmapFont(); camera = new OrthographicCamera(WORLD_WIDTH, WORLD_HEIGHT); camera.position.set(0, (WORLD_HEIGHT / 2) - 1, 0); immediateRenderer = new ImmediateModeRenderer20(SIZE*6, false, true, 0); irt = new Renderer20(SIZE*6, false, true, 1); irt2 = new ImmediateModeRenderer20(SIZE*11, false, true, 1); shapeRenderer = new ShapeRenderer(SIZE); renderer = new Box2DDebugRenderer(true, true, false, true, false, false); //3D camera3D = new PerspectiveCamera(67, WORLD_WIDTH, WORLD_HEIGHT); camera3D.position.set(0, 130f, 250f); camera3D.lookAt(0,150f,0); camera3D.near = 0.1f; camera3D.far = 500f; camera3D.update(); ModelBuilder modelBuilder = new ModelBuilder(); // model = modelBuilder.createSphere(5f, 5f, 5f, 4, 4, GL10.GL_TRIANGLES, // new Material(ColorAttribute.createDiffuse(Color.GREEN)), // Usage.Position | Usage.Normal); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0, -0.8f, -0.2f)); camController = new Camera3DController(camera3D); camController.setFluidSimulator(this); world = new World(new Vector2(0, -9.8f), false); world.setContactListener(this); }
Example #23
Source File: Assets.java From SIFTrain with MIT License | 5 votes |
public static void queueLoading() { internalManager.load("textures/textures.pack.atlas", TextureAtlas.class); internalManager.load("hitsounds/bad.mp3", Sound.class); internalManager.load("hitsounds/good.mp3", Sound.class); internalManager.load("hitsounds/great.mp3", Sound.class); internalManager.load("hitsounds/perfect.mp3", Sound.class); internalManager.load("bigimages/main_menu_background.jpg", Texture.class); internalManager.load("images/hold_background.png", Texture.class); internalManager.load("fonts/combo-font.fnt", BitmapFont.class); internalManager.load("fonts/song-font.fnt", BitmapFont.class); reloadBeatmaps(); }
Example #24
Source File: EngineAssetManager.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
protected EngineAssetManager(FileHandleResolver resolver) { super(resolver); resResolver = new EngineResolutionFileResolver(resolver); setLoader(Texture.class, new TextureLoader(resResolver)); setLoader(TextureAtlas.class, new TextureAtlasLoader(resResolver)); setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver)); setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver)); Texture.setAssetManager(this); }
Example #25
Source File: FilteredSelectBox.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public FilteredSelectBoxStyle(BitmapFont font, Color fontColor, Drawable background, ScrollPaneStyle scrollStyle, ListStyle listStyle, TextFieldStyle textFieldStyle) { this.font = font; this.fontColor.set(fontColor); this.background = background; this.scrollStyle = scrollStyle; this.listStyle = listStyle; this.textFieldStyle = textFieldStyle; }
Example #26
Source File: RendererSystem.java From Entitas-Java with MIT License | 5 votes |
public RendererSystem(CoreContext context, ShapeRenderer sr, Camera cam, Batch batch, BitmapFont font) { this.sr = sr; this.cam = cam; this.batch = batch; this.font = font; _group = context.getGroup(CoreMatcher.View()); _groupScore = context.getGroup(CoreMatcher.Score()); _groupTextureView = context.getGroup(CoreMatcher.TextureView()); }
Example #27
Source File: ConnectTheDotsGenerator.java From ud405 with MIT License | 5 votes |
@Override public void create () { Gdx.input.setInputProcessor(this); spriteBatch = new SpriteBatch(); shapeRenderer = new ShapeRenderer(); bitmapFont = new BitmapFont(); resetDots(); }
Example #28
Source File: BubbleLevelScreen.java From ud405 with MIT License | 5 votes |
@Override public void show() { axisViewport = new FitViewport(WORLD_SIZE, WORLD_SIZE); renderer = new ShapeRenderer(); renderer.setAutoShapeType(true); batch = new SpriteBatch(); textViewport = new ScreenViewport(); font = new BitmapFont(); font.getData().setScale(TEXT_SCALE); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); maxAcceleration = 0; minAcceleration = Float.MAX_VALUE; }
Example #29
Source File: Tutorial.java From martianrun with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); batch.draw(textureRegion, bounds.x, bounds.y, bounds.width, bounds.height); font.drawWrapped(batch, text, bounds.x, bounds.y, bounds.width, BitmapFont.HAlignment.CENTER); }
Example #30
Source File: PausedLabel.java From martianrun with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (GameManager.getInstance().getGameState() == GameState.PAUSED) { font.drawWrapped(batch, Constants.PAUSED_LABEL, bounds.x, bounds.y, bounds.width, BitmapFont.HAlignment.CENTER); } }