使用位图字体绘图不会显示任何内容

时间:2013-03-07 18:45:28

标签: android text fonts libgdx bitmap-fonts

我做错了什么??

public class Memoration implements ApplicationListener {
private OrthographicCamera camera;
public SpriteBatch batch;
public static float w, h;
public BitmapFont clickBitmapFont;

@Override
public void create() {
    camera = new OrthographicCamera(1, h / w);
    batch = new SpriteBatch();
    w = Gdx.graphics.getWidth();
    h = Gdx.graphics.getHeight();
    Matrix4 normalProjection = new Matrix4().setToOrtho2D(0, 0, w, h); // acording to http://stackoverflow.com/questions/12895822/how-to-draw-a-bitmapfont-in-libgdx it should work...
    batch.setProjectionMatrix(normalProjection);

    clickBitmapFont = new BitmapFont(Gdx.files.internal("data/font.fnt"),Gdx.files.internal("data/font.png"),false);
    clickBitmapFont.setColor(Color.BLUE);
}

@Override
public void dispose() {
    batch.dispose();
}

@Override
public void render() {
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    batch.setProjectionMatrix(camera.combined);

    batch.begin();
    draw();
    batch.end();
}

    public void draw(){
    clickBitmapFont.draw(batch, "hello StackOverflow", 100, 100);
}
}

将BMFont用于.fnt和.png,这可能不是问题..

0 个答案:

没有答案