Back to project page AndriyVoronaSpaceAttack.
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.
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(); } }