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


Java FreeTypeFontGenerator類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator的典型用法代碼示例。如果您正苦於以下問題:Java FreeTypeFontGenerator類的具體用法?Java FreeTypeFontGenerator怎麽用?Java FreeTypeFontGenerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FreeTypeFontGenerator類屬於com.badlogic.gdx.graphics.g2d.freetype包,在下文中一共展示了FreeTypeFontGenerator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: loadAssets

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void loadAssets() {
    InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
    assetManager = new AssetManager(fileHandler);
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));

    assetManager.load(SKIN_PATH, Skin.class);
    assetManager.load(MASTER_PATH, TextureAtlas.class);
    assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
    assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
    assetManager.load(GOOD_PATH, Sound.class);
    assetManager.load(HALF_PATH, Sound.class);
    assetManager.load(BAD_PATH, Sound.class);
    assetManager.finishLoading();
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:17,代碼來源:Polymorph.java

示例4: initUtils

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void initUtils() {
    //init camera & viewport
    camera = new OrthographicCamera();
    viewport = new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT, camera);
    viewport.apply(true);
    camera.update();

    //init sprite batch
    batch = new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);

    //init font
    FreeTypeFontGenerator fontGenerator = polymorph.getAssetManager().get(Polymorph.FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    FreeTypeFontParameter fontSettings = new FreeTypeFontParameter();
    fontSettings.size = 80;
    fontSettings.minFilter = TextureFilter.Linear;
    fontSettings.magFilter = TextureFilter.Linear;
    font = fontGenerator.generateFont(fontSettings);
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:20,代碼來源:GameScreen.java

示例5: 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

示例6: 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

示例7: 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

示例8: HUD

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private HUD() {
    stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
    stage.addListener(inputListener = new InputListener(true));
    Gdx.input.setInputProcessor(stage);

    fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
    skin = new Skin(Gdx.files.internal("uiskin.json"));
    createFlashImage();
    createProgressLabel();
    createInfoLabel();
    createLevelCompleteUI();
    hideLevelComplete();

    if (Globals.isMobile()) {
        createMobileButtons();
    }
}
 
開發者ID:alexschimpf,項目名稱:joe,代碼行數:18,代碼來源:HUD.java

示例9: createReplayButton

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void createReplayButton() {
    FreeTypeFontGenerator.FreeTypeFontParameter fontParam = new FreeTypeFontGenerator.FreeTypeFontParameter();
    fontParam.size = Gdx.graphics.getWidth() / 8;

    TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
    style.font = fontGenerator.generateFont(fontParam);
    style.fontColor = Color.WHITE;

    final TextButton playButton = new TextButton("REPLAY?", skin);
    playButton.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    playButton.setPosition(0, 0);
    playButton.setStyle(style);
    playButton.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            game.setScreen(new Driver(game));
        }
    });

    stage.addActor(playButton);
}
 
開發者ID:alexschimpf,項目名稱:joe,代碼行數:22,代碼來源:IterationComplete.java

示例10: 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

示例11: getFontIcon

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private Drawable getFontIcon(FileChooser.FileItem item) {
    FileHandle fileHandle = item.getFile();
    BitmapFont bitmapFont;
    try {
        FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
        FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
        parameter.size = CB.getScaledInt(50);
        parameter.characters = SkinFont.DEFAULT_CHARACTER;
        parameter.genMipMaps = true;
        parameter.minFilter = Texture.TextureFilter.MipMapNearestNearest;
        bitmapFont = generator.generateFont(parameter);
    } catch (Exception e) {
        return getImageIcon(item);
    }

    Drawable drawable = new BitmapFontDrawable(bitmapFont, item.getFile().nameWithoutExtension());
    return drawable;
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:19,代碼來源:FontFileIconProvider.java

示例12: Font

import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public Font(final Application APP, String fileName, String filePath, int size, boolean filter)
{
    // ASSIGN ATTRIBUTES
    this.size = size;

    FreetypeFontLoader.FreeTypeFontLoaderParameter parameter = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
    FileHandleResolver resolver = new InternalFileHandleResolver();

    APP.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    APP.assets.setLoader(BitmapFont.class, ".otf", new FreetypeFontLoader(resolver));

    // GENERATE FONT
    if (filter) // IF FILTER ENABLED
    {
        parameter.fontParameters.genMipMaps = true;
        parameter.fontParameters.minFilter = Texture.TextureFilter.Linear;
        parameter.fontParameters.magFilter = Texture.TextureFilter.Linear;
    }
    parameter.fontFileName = filePath;
    parameter.fontParameters.size = size;

    APP.assets.load(fileName, BitmapFont.class, parameter);
    APP.assets.finishLoading();

    font = APP.assets.get(fileName, BitmapFont.class);
}
 
開發者ID:NahroTo,項目名稱:Fruit-Destroyer,代碼行數:27,代碼來源:Font.java

示例13: 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

示例14: 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

示例15: 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


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