当前位置: 首页>>代码示例>>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;未经允许,请勿转载。