Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package com.mygdx.game.desktop;
  2.  
  3. import com.badlogic.gdx.*;
  4. import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
  5. import com.badlogic.gdx.graphics.*;
  6. import com.badlogic.gdx.graphics.Texture.TextureFilter;
  7. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  8. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  9. import com.badlogic.gdx.math.Vector2;
  10. import com.badlogic.gdx.utils.Align;
  11.  
  12. public class FontProblem extends ApplicationAdapter {
  13.     SpriteBatch batch;
  14.     BitmapFont font;
  15.  
  16.     public void create () {
  17.         batch = new SpriteBatch();
  18.        
  19.         font = new BitmapFont();
  20.         font.setUseIntegerPositions(false);
  21.         font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
  22.     }
  23.  
  24.     public void render () {
  25.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  26.        
  27.         renderTest(new Vector2(100, 50), true, true);
  28.         renderTest(new Vector2(150, 50), false, true);
  29.         renderTest(new Vector2(200, 50), true, false);
  30.     }
  31.    
  32.     public void renderTest(Vector2 pos, boolean x, boolean y) {
  33.         float rad = 10.0f;
  34.         float angle = (System.currentTimeMillis() % 5000) / 5000.0f * (float)Math.PI*2;
  35.        
  36.         batch.enableBlending();
  37.         batch.begin();
  38.         font.setColor(Color.WHITE);
  39.         font.draw(batch,
  40.                   "5",
  41.                   pos.x + (float)Math.cos(angle)*rad * (x ? 1 : 0),
  42.                   pos.y + (float)Math.sin(angle)*rad *(y ? 1 : 0),
  43.                   0,
  44.                   Align.left,
  45.                   false
  46.                   );
  47.         batch.end();
  48.     }    
  49.  
  50.     public static void main (String[] args) throws Exception {
  51.         new LwjglApplication(new FontProblem());
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement