Java Code Examples for com.badlogic.gdx.graphics.g2d.BitmapFont

The following examples show how to use com.badlogic.gdx.graphics.g2d.BitmapFont. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: flopsydroid   Source File: FlopsyScreen.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: Klooni1010   Source File: SkinLoader.java    License: GNU General Public License v3.0 6 votes vote down vote up
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 3
Source Project: ud405   Source File: IciclesScreen.java    License: MIT License 6 votes vote down vote up
@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 4
Source Project: ud405   Source File: IciclesScreen.java    License: MIT License 6 votes vote down vote up
@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 5
Source Project: skin-composer   Source File: MainListener.java    License: MIT License 6 votes vote down vote up
@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 6
Source Project: cocos-ui-libgdx   Source File: FontUtilTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: vis-ui   Source File: HighlightTextArea.java    License: Apache License 2.0 6 votes vote down vote up
@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
@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 Project: jorbs-spire-mod   Source File: WrathCardIconPatch.java    License: MIT License 5 votes vote down vote up
@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 10
Source Project: gdx-ai   Source File: TabbedPane.java    License: Apache License 2.0 5 votes vote down vote up
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 Project: gdx-proto   Source File: SmartFontGenerator.java    License: Apache License 2.0 5 votes vote down vote up
private void saveFontToFile(BitmapFont font, int fontSize, String fontName, PixmapPacker packer) {
	FileHandle fontFile = getFontFile(fontName + ".fnt"); // .fnt path
	FileHandle pixmapDir = getFontFile(fontName); // png dir path
	BitmapFontWriter.setOutputFormat(BitmapFontWriter.OutputFormat.Text);

	String[] pageRefs = BitmapFontWriter.writePixmaps(packer.getPages(), pixmapDir, fontName);
	Gdx.app.debug(TAG, String.format("Saving font [%s]: fontfile: %s, pixmapDir: %s\n", fontName, fontFile, pixmapDir));
	// here we must add the png dir to the page refs
	for (int i = 0; i < pageRefs.length; i++) {
		pageRefs[i] = fontName + "/" + pageRefs[i];
	}
	BitmapFontWriter.writeFont(font.getData(), pageRefs, fontFile, new BitmapFontWriter.FontInfo(fontName, fontSize), 1, 1);
}
 
Example 12
Source Project: uracer-kotd   Source File: BitmapFontFactory.java    License: Apache License 2.0 5 votes vote down vote up
public static void dispose () {
	for (BitmapFont f : fontCache.values()) {
		f.dispose();
	}

	fontCache.clear();
}
 
Example 13
Source Project: Norii   Source File: Utility.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadFreeTypeFontAsset(final String fontName, final int size) {
	if (checkValidString(fontName)) {
		assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(filePathResolver));
		assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(filePathResolver));

		final FreeTypeFontLoaderParameter myFont = new FreeTypeFontLoaderParameter();
		myFont.fontFileName = fontName;
		myFont.fontParameters.size = size;
		myFont.fontParameters.borderWidth = 0.5f;
		myFont.fontParameters.color = Color.LIGHT_GRAY;
		myFont.fontParameters.shadowOffsetX = 2;
		myFont.fontParameters.shadowOffsetY = 2;
		assetManager.load(fontName, BitmapFont.class, myFont);
	}
}
 
Example 14
Source Project: Norii   Source File: Utility.java    License: Apache License 2.0 5 votes vote down vote up
public static LabelStyle createLabelStyle(final String fontPath, final int size, final int borderWidth, final Color color, final int shadowX, final int shadowY) {
	final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(fontPath));
	final FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
	parameter.size = size;
	parameter.borderWidth = borderWidth;
	parameter.color = color;
	parameter.shadowOffsetX = shadowX;
	parameter.shadowOffsetY = shadowY;
	final BitmapFont font = generator.generateFont(parameter);
	final LabelStyle labelStyle = new LabelStyle();
	labelStyle.font = font;
	return labelStyle;
}
 
Example 15
Source Project: ud405   Source File: FPSCounterScreen.java    License: MIT License 5 votes vote down vote up
@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 16
Source Project: riiablo   Source File: StatLabel.java    License: Apache License 2.0 5 votes vote down vote up
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 17
Source Project: RuinsOfRevenge   Source File: ScreenGameMap.java    License: MIT License 5 votes vote down vote up
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 18
Source Project: ud405   Source File: MyScreen.java    License: MIT License 5 votes vote down vote up
@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 19
Source Project: martianrun   Source File: Score.java    License: Apache License 2.0 5 votes vote down vote up
@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 20
Source Project: TerraLegion   Source File: ResourceManager.java    License: MIT License 5 votes vote down vote up
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 21
@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 22
Source Project: ud405   Source File: ConnectTheDots.java    License: MIT License 5 votes vote down vote up
@Override
public void create() {
    spriteBatch = new SpriteBatch();
    bitmapFont = new BitmapFont();
    floatDots = vector2ArrayToFloatArray(dots);
    shapeRenderer = new ShapeRenderer();

}
 
Example 23
Source Project: riiablo   Source File: CharacterPanel.java    License: Apache License 2.0 5 votes vote down vote up
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 24
Source Project: riiablo   Source File: TextButton.java    License: Apache License 2.0 5 votes vote down vote up
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 25
Source Project: libgdx-demo-pax-britannica   Source File: Settings.java    License: MIT License 5 votes vote down vote up
@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 26
Source Project: fluid-simulator-v2   Source File: FluidSimulatorGeneric.java    License: Apache License 2.0 5 votes vote down vote up
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 27
Source Project: SIFTrain   Source File: Assets.java    License: MIT License 5 votes vote down vote up
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 28
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 29
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 30
Source Project: Entitas-Java   Source File: RendererSystem.java    License: MIT License 5 votes vote down vote up
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 31
Source Project: ud405   Source File: ConnectTheDotsGenerator.java    License: MIT License 5 votes vote down vote up
@Override
public void create () {
    Gdx.input.setInputProcessor(this);
    spriteBatch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    bitmapFont = new BitmapFont();
    resetDots();
}
 
Example 32
Source Project: ud405   Source File: BubbleLevelScreen.java    License: MIT License 5 votes vote down vote up
@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 33
Source Project: martianrun   Source File: Tutorial.java    License: Apache License 2.0 5 votes vote down vote up
@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 34
Source Project: martianrun   Source File: PausedLabel.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 35
Source Project: vis-ui   Source File: VisTextButton.java    License: Apache License 2.0 4 votes vote down vote up
public VisTextButtonStyle (Drawable up, Drawable down, Drawable checked, BitmapFont font) {
	super(up, down, checked, font);
}
 
Example 36
Source Project: riiablo   Source File: LabelButton.java    License: Apache License 2.0 4 votes vote down vote up
public LabelButton(BitmapFont font) {
  super(font);
  init();
}
 
Example 37
Source Project: xibalba   Source File: Main.java    License: MIT License 4 votes vote down vote up
/**
 * Setup & load the main menu.
 */
public void create() {
  // Debug shit
  debug = new Debug();

  // Load custom font
  assets = new AssetManager();
  FreeTypeFontGenerator generator =
      new FreeTypeFontGenerator(Gdx.files.internal("ui/Aller_Rg.ttf"));
  FreeTypeFontGenerator.FreeTypeFontParameter parameter =
      new FreeTypeFontGenerator.FreeTypeFontParameter();
  parameter.size = 12;
  BitmapFont font = generator.generateFont(parameter);
  generator.dispose();

  // Create UI skin
  skin = new Skin();
  skin.add("Aller", font, BitmapFont.class);
  skin.addRegions(new TextureAtlas(Gdx.files.internal("ui/uiskin.atlas")));
  skin.load(Gdx.files.internal("ui/uiskin.json"));
  skin.getFont("default-font").getData().markupEnabled = true;

  // Setup text colors
  Colors.put("LIGHT_GRAY", parseColor("c2c2c2"));
  Colors.put("DARK_GRAY", parseColor("666666"));
  Colors.put("CYAN", parseColor("67C8CF"));
  Colors.put("RED", parseColor("D67474"));
  Colors.put("YELLOW", parseColor("E0DFB1"));
  Colors.put("GREEN", parseColor("67CF8B"));

  // Environment colors
  Colors.put("forestFloor", parseColor("78AD8A"));
  Colors.put("forestFloorWet", parseColor("70BBAD"));
  Colors.put("forestTree-1", parseColor("67CF8B"));
  Colors.put("forestTree-2", parseColor("77E09B"));
  Colors.put("forestTree-3", parseColor("4AC775"));

  Colors.put("caveFloor-1", parseColor("7A7971"));
  Colors.put("caveFloor-2", parseColor("8C8B82"));
  Colors.put("caveFloor-3", parseColor("696862"));
  Colors.put("caveFloorWet", parseColor("71A48E"));
  Colors.put("caveWall", parseColor("66655C"));

  Colors.put("waterShallowLightBlue", parseColor("67C8CF"));
  Colors.put("waterShallowDarkBlue", parseColor("139EA8"));
  Colors.put("waterDeepLightBlue", parseColor("139EA8"));
  Colors.put("waterDeepDarkBlue", parseColor("0B7880"));

  Colors.put("waterShallowLightGreen", parseColor("67CFAB"));
  Colors.put("waterShallowDarkGreen", parseColor("13A88F"));
  Colors.put("waterDeepLightGreen", parseColor("13A88F"));
  Colors.put("waterDeepDarkGreen", parseColor("0B8074"));

  Colors.put("fire-1", parseColor("ED6161"));
  Colors.put("fire-2", parseColor("EDBE61"));
  Colors.put("fire-3", parseColor("ED9661"));

  // Decoration colors
  Colors.put("stone", Colors.get("LIGHT_GRAY"));
  Colors.put("bridge", parseColor("969482"));

  // Background colors
  Colors.put("screenBackground", parseColor("293033"));
  Colors.put("forestBackground", parseColor("29332F"));
  Colors.put("caveBackground", parseColor("293033"));

  // Tween manager
  tweenManager = new TweenManager();
  Tween.setCombinedAttributesLimit(4);
  Tween.registerAccessor(Sprite.class, new SpriteAccessor());

  // Cameras
  handheldCamera = new HandheldCamera();
  cameraShake = new CameraShake();

  // Start the main menu
  setScreen(new LoadingScreen(this));
}
 
Example 38
Source Project: ud406   Source File: GigaGalHud.java    License: MIT License 4 votes vote down vote up
public GigaGalHud() {
    this.viewport = new ExtendViewport(Constants.HUD_VIEWPORT_SIZE, Constants.HUD_VIEWPORT_SIZE);
    font = new BitmapFont();
    font.getData().setScale(1);
}
 
Example 39
Source Project: graphicsfuzz   Source File: Main.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

  if(this.overrideLogger != null){
    Gdx.app.setApplicationLogger(overrideLogger);
  }

  // Only DesktopLauncher sets this.
  if(gl30 == null) {
    // Gdx.gl30 could also be null though.
    gl30 = Gdx.gl30;
  }

  Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
  Gdx.graphics.getGL20().glEnable(GL20.GL_DEPTH_TEST);
  Gdx.graphics.getGL20().glDepthFunc(GL20.GL_LESS);

  standardMesh = buildFullScreenQuadMesh();

  if(standaloneRenderJob != null) {
    if (standaloneRenderJob.isSetComputeSource()) {
      updateState(WorkerState.COMPUTE_STANDALONE_PREPARE);
    } else {
      updateState(WorkerState.IMAGE_STANDALONE_PREPARE);
    }
    return;
  }

  PlatformInfoUtil.getPlatformDetails(platformInfoJson);
  PlatformInfoUtil.getGlVersionInfo(platformInfoJson, gl30);

  sanityReferenceImage = createPixelBuffer();
  sanityCheckImage = createPixelBuffer();
  sanityCheckImageTmp = createPixelBuffer();

  GdxStage = new Stage(new ScreenViewport());
  Label.LabelStyle label1Style = new Label.LabelStyle();
  label1Style.font = new BitmapFont();
  label1Style.fontColor = Color.WHITE;

  DisplayContent = new StringBuilder();
  DisplayLabel = new Label(DisplayContent.toString(), label1Style);
  DisplayLabel.setPosition(WIDTH + DISPLAY_TXT_MARGIN, 0);
  DisplayLabel
      .setSize(Gdx.graphics.getWidth() - WIDTH - DISPLAY_TXT_MARGIN - 10, Gdx.graphics.getHeight() - 10);
  DisplayLabel.setAlignment(Align.topLeft);
  DisplayContent = new StringBuilder();
  GdxStage.addActor(DisplayLabel);
}
 
Example 40
private synchronized void measure(){
	
	if (Thread.currentThread().getName().equals("SHPD Actor Thread")){
		throw new RuntimeException("Text measured from the actor thread!");
	}
	
	if ( text == null || text.equals("") ) {
		text = "";
		width=height=0;
		visible = false;
		return;
	} else {
		visible = true;
	}
	
	font = getFont(size);
	
	if (font != null){
		GlyphLayout glyphs = new GlyphLayout( font, text);
		
		for (char c : text.toCharArray()) {
			BitmapFont.Glyph g = font.getData().getGlyph(c);
			if (g == null || (g.id != c)){
				Game.reportException(new Throwable("font file " + font.toString() + " could not render " + c));
			}
		}
		
		//We use the xadvance of the last glyph in some cases to fix issues
		// with fullwidth punctuation marks in some asian scripts
		BitmapFont.Glyph lastGlyph = font.getData().getGlyph(text.charAt(text.length()-1));
		if (lastGlyph != null && lastGlyph.xadvance > lastGlyph.width*1.5f){
			width = glyphs.width - lastGlyph.width + lastGlyph.xadvance;
		} else {
			width = glyphs.width;
		}
		
		//this is identical to l.height in most cases, but we force this for consistency.
		height = Math.round(size*0.75f);
		renderedHeight = glyphs.height;
	}
}