Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mygdx.game.desktop;
- import com.badlogic.gdx.*;
- import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
- import com.badlogic.gdx.graphics.*;
- import com.badlogic.gdx.graphics.Texture.TextureFilter;
- import com.badlogic.gdx.graphics.g2d.BitmapFont;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.math.Vector2;
- import com.badlogic.gdx.utils.Align;
- public class FontProblem extends ApplicationAdapter {
- SpriteBatch batch;
- BitmapFont font;
- public void create () {
- batch = new SpriteBatch();
- font = new BitmapFont();
- font.setUseIntegerPositions(false);
- font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
- }
- public void render () {
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- renderTest(new Vector2(100, 50), true, true);
- renderTest(new Vector2(150, 50), false, true);
- renderTest(new Vector2(200, 50), true, false);
- }
- public void renderTest(Vector2 pos, boolean x, boolean y) {
- float rad = 10.0f;
- float angle = (System.currentTimeMillis() % 5000) / 5000.0f * (float)Math.PI*2;
- batch.enableBlending();
- batch.begin();
- font.setColor(Color.WHITE);
- font.draw(batch,
- "5",
- pos.x + (float)Math.cos(angle)*rad * (x ? 1 : 0),
- pos.y + (float)Math.sin(angle)*rad *(y ? 1 : 0),
- 0,
- Align.left,
- false
- );
- batch.end();
- }
- public static void main (String[] args) throws Exception {
- new LwjglApplication(new FontProblem());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement