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


Java BitmapFont類代碼示例

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


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

示例1: GameState

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public GameState(String name, String tmx, StateManager manager) {
	this.tmx = tmx;
	setManager(manager);
	if(name!=null)
	this.name = name;
	else
		this.name = "";
	sprites = new ObjectMap<String, Sprite>();
	animations = new ObjectMap<String, Animation<String>>();
	fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
	particle_effects = new ObjectMap<String, ParticleEffectPool>();
	pvalues = new Array<String>();
	time_scale = 1f;
	shaders = new ObjectMap<String, ShaderProgram>();
	svalues = new Array<String>();
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:17,代碼來源:GameState.java

示例2: onFinishedLoading

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
private void onFinishedLoading() {
	BitmapFont main19Font = assetManager.get(MAIN_FONT_19_PATH());
	BitmapFont main22Font = assetManager.get(MAIN_FONT_22_PATH());
	BitmapFont letter20Font = assetManager.get(LETTER_FONT_20_PATH());
	BitmapFont handwritten20Font = assetManager
			.get(HANDWRITTEN_FONT_20_PATH());

	ObjectMap<String, Object> fontMap = new ObjectMap<String, Object>();
	fontMap.put("main-19", main19Font);
	fontMap.put("main-22", main22Font);
	fontMap.put("letter-20", letter20Font);
	fontMap.put("handwritten-20", handwritten20Font);
	assetManager.load(SKIN_PATH, Skin.class,
			new SkinLoader.SkinParameter(SKIN_TEXTURE_ATLAS_PATH, fontMap));
	assetManager.finishLoadingAsset(SKIN_PATH);

	// game.setUISkin(assetManager.get(SKIN_PATH));
	VisUI.load();
	game.setUISkin(VisUI.getSkin());

	// Notify loaded screens
	game.getScreen("serverBrowser").finishLoading();

	game.pushScreen("mainMenu");
}
 
開發者ID:eskalon,項目名稱:ProjektGG,代碼行數:26,代碼來源:LoadingScreen.java

示例3: renderGuiFpsCounter

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
private void renderGuiFpsCounter(SpriteBatch batch) {
    float x = cameraGUI.viewportWidth - 55;
    float y = cameraGUI.viewportHeight - 15;
    int fps = Gdx.graphics.getFramesPerSecond();
    BitmapFont fpsFont = Assets.instance.fonts.defaultNormal;
    if (fps >= 45) {
        // 45 or more FPS show up in green
        fpsFont.setColor(0, 1, 0, 1);
    } else if (fps >= 30) {
        // 30 or more FPS show up in yellow
        fpsFont.setColor(1, 1, 0, 1);
    } else {
        // less than 30 FPS show up in red
        fpsFont.setColor(1, 0, 0, 1);
    }
    fpsFont.draw(batch, "FPS: " + fps, x, y);
    fpsFont.setColor(1, 1, 1, 1);
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:19,代碼來源:WorldRenderer.java

示例4: AssetFonts

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public AssetFonts() {
    // Create three fonts using libGdx's 15px bitmap font
    defaultSmall = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);
    defaultNormal = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);
    defaultBig = new BitmapFont(Gdx.files.internal("images/arial-15.fnt"), true);

    // set font sizes
    defaultSmall.getData().setScale(0.75f);
    defaultNormal.getData().setScale(1.0f);
    defaultBig.getData().setScale(2.0f);

    // enable linear texture filtering for smooth fonts
    defaultSmall.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    defaultNormal.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    defaultBig.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:17,代碼來源:Assets.java

示例5: GameOver

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public GameOver(GameStateManager gsm, int score) {
    super(gsm);
    this.score = score;
    camera.setToOrtho(false, FlappyBaran.WIDTH / 2, FlappyBaran.HEIGHT / 2);
    background = new Texture("backgrnd.jpg");
    gameover = new Texture("gameover.png");
    font = new BitmapFont();
    prefs = Gdx.app.getPreferences("FlappyBaran");

    if (!prefs.contains("highScore")) {
        prefs.putInteger("highScore", 0);
    }

    prevHighScore = getHighScore();

    if (prevHighScore < this.score) {
        setHighScore(this.score);
        highscore = this.score;
    } else {
        highscore = prevHighScore;
    }

}
 
開發者ID:kirdmiv,項目名稱:Flappy-Baranus,代碼行數:24,代碼來源:GameOver.java

示例6: Hud

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public Hud(SpriteBatch sb) {
    countKill = 0;
    viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());

    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.setFillParent(true);
    table.top();

    countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(countKillLabel).expandX().padTop(10);
    table.add().expandX();
    table.add().expandX();
    table.add().expandX();
    stage.addActor(table);

}
 
開發者ID:MSLacerda,項目名稱:DarkDay,代碼行數:20,代碼來源:Hud.java

示例7: FilledIconBar

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public FilledIconBar(Texture heartTexture, BitmapFont font) {
    super();

    this.font = font;

    // add heart icon
    this.heartImageWidget = new ImageWidget(heartTexture);
    this.heartImageWidget.setPosition(0, 0);
    this.addWidget(this.heartImageWidget);

    // add health widget
    this.filledBar = new FilledBar(this.font);
    this.filledBar.setPosition(40, 6);
    this.filledBar.setDimension(80, 20);
    this.addWidget(this.filledBar);
}
 
開發者ID:opensourcegamedev,項目名稱:SpaceChaos,代碼行數:17,代碼來源:FilledIconBar.java

示例8: loadFonts

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
private void loadFonts(TiledMap data, String atlasname) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String ffcheck = "Font";
	for (MapObject o : objects) {
		String name = o.getName();
		BitmapFont font = null;
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		String fontfile = properties.get("font_file", String.class);
		if (fontfile != null && type != null && type.equals(ffcheck)) {
			boolean markup = properties.get("markup", false, boolean.class);
			game.loadFont(fontfile, atlasname);
			game.getAssetManager().finishLoading();
			font = game.getFont(fontfile);
			fonts.put(name, font);
			font.getData().markupEnabled = markup;
		}
	}
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:20,代碼來源:GameState.java

示例9: createFont

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的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

示例10: createFont

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的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

示例11: create

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
@Override
public void create() {
    VisUI.load();
    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    img = new Texture("splash.png");
    font = new BitmapFont(Gdx.files.internal("font/openSans.fnt"), Gdx.files.internal("font/openSans.png"), false, true);

    window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();

    // start loading
    loadingTask = new LoadingTask();
    try {
        loadingTask.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:mbrlabs,項目名稱:gdx-splash,代碼行數:19,代碼來源:SplashScreen.java

示例12: MenuScreen

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public MenuScreen() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
    viewport.apply();
    camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
    camera.update();
    betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
    betaText.getData().setScale(0.35f);
    logo = new Sprite(new Texture("logo.png"));
    Random r = new Random();
    background = new Particle[r.nextInt(55 - 45) + 45];
    for (int i = 0; i < background.length; i++) {
        int size = r.nextInt(4) + 1;
        int x = r.nextInt(Game.WIDTH);
        int y = r.nextInt(Game.HEIGHT);
        background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size);
    }
    musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
    musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
    play = new CenteredButton(500, "buttons/play.png");
    music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
    music.setScale(4f);
}
 
開發者ID:MrGussio,項目名稱:EarthInvadersGDX,代碼行數:24,代碼來源:MenuScreen.java

示例13: show

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
@Override
public void show() {
	Gdx.input.setInputProcessor(stage);
	GameUtils.getGame().assets.put("Players/player.png", Texture.class);
	GameUtils.getGame().assets.put("World/grass.png", Texture.class);
	GameUtils.getGame().assets.put("Fonts/HUDFont.fnt", BitmapFont.class);
	
	switch(Gdx.app.getType()) {
	case Android:
		GameUtils.getGame().assets.put("Controls/touchBackground.png", Texture.class);
		GameUtils.getGame().assets.put("Controls/touchKnob.png", Texture.class);
		break;
	default:
		break;
	}
}
 
開發者ID:Arcxes,項目名稱:CursedEcho,代碼行數:17,代碼來源:LoginScreen.java

示例14: create

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
@Override
public void create() {
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.setColor(0, 0, 1, 1);

    // Origin
    TextureAtlas originTextureAtlas = new TextureAtlas(ORIGIN_PATH + "/test.atlas");
    Skin originSkin = new Skin(originTextureAtlas);
    originTextureRegion = originSkin.getRegion("badlogic");

    // Encrypt
    SimpleXorCryptoEncryptor.process("123", "atlas", "encryptedAtlas");

    // Decrypt
    CryptTextureAtlas cryptTextureAtlas = new CryptTextureAtlas(crypto, ENCRYPTED_PATH + "/test.atlas");
    Skin skin = new Skin(cryptTextureAtlas);
    decryptTextureRegion = skin.getRegion("badlogic");
}
 
開發者ID:akivamu,項目名稱:libgdx-crypt-texture,代碼行數:21,代碼來源:TestCryptTextureAtlas.java

示例15: MessageWindow

import com.badlogic.gdx.graphics.g2d.BitmapFont; //導入依賴的package包/類
public MessageWindow(String message, BitmapFont font, float width, float height) {
    setTouchable(Touchable.enabled);
    setBounds(width / 2 - width / 4, height / 2 - height / 10, width / 2, height / 5);
    texture = new Texture("theme/basic/ui/Window.png");
    this.message = message;
    table = new Table();
    table.setSize(getWidth(), getHeight());
    table.align(Align.center | Align.top);
    table.setPosition(getX(), getY());
    Label label = new Label(message, new Label.LabelStyle(font, Color.BLACK));
    label.setWrap(true);
    label.setFontScale(0.7f);
    Label label2 = new Label("Tap to continue", new Label.LabelStyle(font, Color.BLACK));
    label2.setFontScale(0.6f);
    table.add(label).width(getWidth());
    table.row();
    table.add(label2).width(getWidth()).expandY();
    table.pad(0, 30, 0, 30);
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:20,代碼來源:MessageWindow.java


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