예제 #1
0
  public CommonDrawer() {
    myTextureChecker = new TextureChecker();
    w = Gdx.graphics.getWidth();
    h = Gdx.graphics.getHeight();
    r = w / h;
    mySpriteBatch = new SpriteBatch();

    final FileHandle fontFile = FileManager.getInstance().getFontsDirectory().child("main.fnt");
    myFont = new BitmapFont(fontFile, true);
    myFont.setUseIntegerPositions(false);

    myOrigFontHeight = myFont.getXHeight();

    layout = new GlyphLayout();
  }
예제 #2
0
  public void drawString(String s, float x, float y, float fontSize, boolean centered, Color col) {
    if (s == null) return;
    myTextureChecker.onString(myFont.getRegion().getTexture());
    myFont.setColor(col);
    myFont.getData().setScale(fontSize / myOrigFontHeight);
    if (!centered) {
      myFont.draw(mySpriteBatch, s, x, y);
      return;
    }

    // http://www.badlogicgames.com/wordpress/?p=3658
    layout.reset();
    layout.setText(myFont, s);
    x -= layout.width / 2;
    y -= layout.height / 2;
    myFont.draw(mySpriteBatch, layout, x, y);
  }
예제 #3
0
 public void dispose() {
   mySpriteBatch.dispose();
   myFont.dispose();
 }