Пример #1
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);
  }