Android Open Source - AndriyVoronaSpaceAttack Font Writer






From Project

Back to project page AndriyVoronaSpaceAttack.

License

The source code is released under:

GNU General Public License

If you think the Android project AndriyVoronaSpaceAttack listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.vorona.game;
//from www . j  a va 2 s.  c om
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.Stage;

public class FontWriter {

  private static final FreeTypeFontGenerator font  = new FreeTypeFontGenerator(Gdx.files.internal("Munich.ttf"));
  private BitmapFont f;
  
  public FontWriter(int size) {
    // TODO Auto-generated constructor stub
    f = font.generateFont(size);
  }
  
  public void printLeft(String s, Color c, int x, int y, Stage stage){
    f.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    f.setColor(c);
    f.setScale(1, -1);
    stage.getBatch().begin();
    f.draw(stage.getBatch(), s, x, y);
    stage.getBatch().end();
  }
  
  public void printRight(String s, Color c, int x, int y, Stage stage){
    f.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    f.setColor(c);
    f.setScale(1, -1);
    stage.getBatch().begin();
    f.draw(stage.getBatch(), s, Gdx.graphics.getWidth() - f.getBounds(s).width - x, y);
    stage.getBatch().end();
  }
  
  public void printCenter(String s, Color c, int y, Stage stage){
    f.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    f.setColor(c);
    f.setScale(1, -1);
    stage.getBatch().begin();
    f.draw(stage.getBatch(), s, Gdx.graphics.getWidth() / 2 - f.getBounds(s).width / 2, y);
    stage.getBatch().end();
  }
  
}




Java Source Code List

com.vorona.game.AScreen.java
com.vorona.game.Assets.java
com.vorona.game.DScreen.java
com.vorona.game.FontWriter.java
com.vorona.game.GScreen.java
com.vorona.game.LScreen.java
com.vorona.game.MScreen.java
com.vorona.game.VoronaGame.java
com.vorona.game.WScreen.java
com.vorona.game.WaitTimer.java
com.vorona.game.android.AndroidLauncher.java
com.vorona.game.desktop.DesktopLauncher.java