本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeTypeFontGenerator.dispose方法的具體用法?Java FreeTypeFontGenerator.dispose怎麽用?Java FreeTypeFontGenerator.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
的用法示例。
在下文中一共展示了FreeTypeFontGenerator.dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private static BitmapFont createFont(int fontSize , Fonts type) {
FileHandle fontFile = null;
switch(type){
case HEMI_HEAD: fontFile = Gdx.files.internal("fonts/HEMIHEAD.TTF"); break;
case VERA: fontFile = Gdx.files.internal("fonts/Vera.ttf"); break;
case VERA_BD: fontFile = Gdx.files.internal("fonts/VeraBd.ttf"); break;
default:
break;
}
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = fontSize;
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
return font;
}
示例2: ChatMessage
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public ChatMessage(String sender, String message) {
super(skin);
// debugAll();
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/DroidSans.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 17;
parameter.minFilter = Texture.TextureFilter.Linear;
parameter.magFilter = Texture.TextureFilter.Linear;
final Label.LabelStyle labelStyle = skin.get("chat-sender", Label.LabelStyle.class);
labelStyle.font = generator.generateFont(parameter);
this.sender = new Label(sender, labelStyle);
this.message = new Label(message, skin.get("chat-message", Label.LabelStyle.class));
this.message.setWrap(true);
add(this.sender).fillX().expandX();
row();
add(this.message).fillX().expandX();
generator.dispose(); // don't forget to dispose to avoid memory leaks!
}
示例3: createFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public static BitmapFont createFont(String fontPath, int size, Color color, Color borderColor, int borderWidth) {
// load font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontPath));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
// https://github.com/libgdx/libgdx/wiki/Gdx-freetype
parameter.size = size;
parameter.borderColor = borderColor;
parameter.borderWidth = borderWidth;
parameter.color = color;
BitmapFont font48 = generator.generateFont(parameter);
generator.dispose();
return font48;
}
示例4: initFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
/**
* 初始遊戲字體
*/
private void initFont() {
FreetypeFontLoader.FreeTypeFontLoaderParameter fontConfig = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
fontConfig.fontFileName = "font.ttf";
fontConfig.fontParameters.size = 22;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameters.size = 18;
f18 = generator.generateFont(parameters);
parameters.size = 22;
f22 = generator.generateFont(parameters);
parameters.size = 24;
f24 = generator.generateFont(parameters);
generator.dispose();
}
示例5: create
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("gfx/fonts/roboto-regular.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 16;
font = generator.generateFont(parameter); // font size 16 pixels
generator.dispose();
music = Gdx.audio.newMusic(Gdx.files.internal("sounds/main.ogg"));
music.setLooping(true);
music.play();
this.setScreen(new MenuScreen(this));
}
示例6: Font
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public Font(String filePath, int size, Color color, boolean filter)
{
// ASSIGN ATTRIBUTES
this.size = size;
this.color = color;
// GENERATE FONT
generator = new FreeTypeFontGenerator(Gdx.files.internal(filePath));
if (filter) // IF FILTER ENABLED
{
parameter.genMipMaps = true;
parameter.minFilter = Texture.TextureFilter.Linear;
parameter.magFilter = Texture.TextureFilter.Linear;
}
parameter.size = size;
parameter.color = color;
font = generator.generateFont(parameter);
generator.dispose();
}
示例7: MenuScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public MenuScreen(TTmath game, OrthoCamera camera, SpriteBatch sb){
this.camera = camera;
this.game = game;
this.sb = sb;
game.resetScore();
game.manageScreens(this);
// game.mainMenuScreen = this;
createStage();
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
font = createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createButton();
}
示例8: createDisplay
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private void createDisplay() {
if(created){
return;
}
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createQuestions();
createStage();
createLabel();
createButton();
createScoreLabel();
createIncorrectLabel();
created = true;
game.problemScreen = this;
}
示例9: GameOverScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public GameOverScreen(TTmath game, OrthoCamera camera, SpriteBatch sb) {
this.game = game;
this.camera = camera;
this.sb = sb;
// game.gameOver = this;
game.setScreen(this);
Gdx.input.setCatchBackKey(true);
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createStage();
createLabel();
createButton();
}
示例10: HighScoreScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public HighScoreScreen(TTmath game, OrthoCamera camera, SpriteBatch sb){
this.game = game;
this.camera = camera;
this.sb = sb;
gameScore = game.getScore();
jScore = new JsonScore();
ArrayList<Score> score = jScore.getHighScoreList();
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createStage();
createLabel("High Scores!", true);
for(int i = 0; i < score.size(); i++){
table.row();
createLabel(score.get(i).getUser(),false);
createLabel(Integer.toString(score.get(i).getScore()),false);
}
createButon();
}
示例11: LevelMenuScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public LevelMenuScreen(TTmath game, OrthoCamera camera, SpriteBatch sb){
this.camera = camera;
this.game = game;
this.sb = sb;
game.manageScreens(this);
// game.levelMenu = this;
Gdx.input.setCatchBackKey(true);
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createStage();
createLabel();
createButton();
}
示例12: initFonts
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private void initFonts() {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/roboto.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter();
params.size = 48;
params.color = new Color(.25f, .25f, .85f, 1);
params.shadowOffsetX = 0;
params.shadowOffsetY = 0;
params.shadowColor = Color.BLACK;
titleFont = generator.generateFont(params);
params = new FreeTypeFontGenerator.FreeTypeFontParameter();
params.size = 32;
params.color = Color.BLACK;
buttonFont = generator.generateFont(params);
generator.dispose();
}
示例13: create
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
@Override
public void create () {
boolean flip = false;
batch = new SpriteBatch();
if (flip) {
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(flip);
cam.update();
batch.setProjectionMatrix(cam.combined);
}
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
parameter.flip = flip;
parameter.genMipMaps = true;
FreeTypeBitmapFontData fontData = generator.generateData(parameter);
ftFont = generator.generateFont(parameter);
generator.dispose();
}
示例14: render
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public void render () {
if (Gdx.input.justTouched()) {
for (int i = 0; i < 10; i++) {
if (font != null) {
font.dispose();
}
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
font = generator.generateFont(parameter);
generator.dispose();
}
for (int i = 0; i < 10; i++)
System.gc();
Gdx.app.log("FreeTypeDisposeTest", "generated 10 fonts");
Gdx.app.log("FreeTypeDisposeTest", Gdx.app.getJavaHeap() + ", " + Gdx.app.getNativeHeap());
}
}
示例15: generateFiles
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
/**
* Convenience method for generating a font, and then writing the fnt and
* png files. Writing a generated font to files allows the possibility of
* only generating the fonts when they are missing, otherwise loading from a
* previously generated file.
*
* @param fontFile
* @param fontSize
* @param destiny
*/
private void generateFiles(String fontName, FileHandle fontFile,
int fontSize, int pageWidth, int pageHeight, FileHandle destiny) {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight,
Pixmap.Format.RGBA8888, 2, false);
FreeTypeFontParameter param = new FreeTypeFontParameter();
param.packer = packer;
param.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
param.size = fontSize;
param.flip = false;
FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator
.generateData(param);
saveFontToFile(fontData, fontSize, fontName, packer, destiny);
generator.dispose();
packer.dispose();
}