當前位置: 首頁>>代碼示例>>Java>>正文


Java FreeTypeFontGenerator.dispose方法代碼示例

本文整理匯總了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;
  }
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:18,代碼來源:Assets.java

示例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!
    }
 
開發者ID:teobaranga,項目名稱:Catan,代碼行數:20,代碼來源:ChatMessage.java

示例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;
}
 
開發者ID:opensourcegamedev,項目名稱:SpaceChaos,代碼行數:17,代碼來源:BitmapFontFactory.java

示例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();
}
 
開發者ID:guojiank,項目名稱:skycity,代碼行數:21,代碼來源:Assets.java

示例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));
}
 
開發者ID:ahmetkasif,項目名稱:Longest-Century,代碼行數:17,代碼來源:Launcher.java

示例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();
}
 
開發者ID:NahroTo,項目名稱:Teleport-Ball,代碼行數:20,代碼來源:Font.java

示例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();
	}
 
開發者ID:n-chunky,項目名稱:TTmath,代碼行數:17,代碼來源:MenuScreen.java

示例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;
}
 
開發者ID:n-chunky,項目名稱:TTmath,代碼行數:20,代碼來源:ProblemScreen.java

示例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();
    }
 
開發者ID:n-chunky,項目名稱:TTmath,代碼行數:20,代碼來源:GameOverScreen.java

示例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();
}
 
開發者ID:n-chunky,項目名稱:TTmath,代碼行數:22,代碼來源:HighScoreScreen.java

示例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();
	}
 
開發者ID:n-chunky,項目名稱:TTmath,代碼行數:17,代碼來源:LevelMenuScreen.java

示例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();
}
 
開發者ID:edvaldoszy,項目名稱:Topicos2015-2,代碼行數:18,代碼來源:MenuScreen.java

示例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();
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:25,代碼來源:FreeTypeTest.java

示例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());
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:22,代碼來源:FreeTypeDisposeTest.java

示例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();
}
 
開發者ID:randombot,項目名稱:skinpacker,代碼行數:30,代碼來源:Ttf2FntGenerator.java


注:本文中的com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。