LibGDX draw BitmapFont at intermediate location (spritebatch)

I want to draw some text using BitmapFont for some temporary location, and then draw some of this place to the final sprite team. I was thinking about drawing for a temporary sprite, but that is not possible. draw a spritebatch on another. How could I do this?

+1
source share
2 answers

Have you tried to write it to pixmap temporarily? When you want to draw it, you can load pixmap into a texture object.

https://github.com/libgdx/libgdx/wiki/Pixmaps

0
source

FrameBuffer. . , , , drawBuffer, .

,

- EDIT -

: useGL20 = true;

public class SpaceMania extends Game  {
@Override
public void create() {
    setScreen(new ScreenView());
}

}

class ScreenView implements Screen{
    InputMultiplexer input;
    FrameBuffer buffer;

    SpriteBatch screenBatch;
    ShapeRenderer shape;

    @Override
    public void render(float delta) {
    //Draw Buffer
    drawBuffer();


    //Draw buffer to screen
    screenBatch.begin();
    screenBatch.draw(buffer.getColorBufferTexture(), 0,0,600,200);
    screenBatch.end();
    }

    public void drawBuffer(){
    buffer.begin();
    shape.begin(ShapeType.FilledCircle);
    shape.setColor(Color.RED);
    shape.filledCircle(50, 50, 50);
    shape.end();
    buffer.end();
    }
    @Override
    public void show() {
    buffer = new FrameBuffer(Format.RGBA8888, 200, 200,false);
    screenBatch = new SpriteBatch();
    shape = new ShapeRenderer();
    }

    @Override
    public void hide() {
    // TODO Auto-generated method stub

    }

    @Override
    public void resize(int width, int height) {
    // TODO Auto-generated method stub

    }

    @Override
    public void pause() {
    // TODO Auto-generated method stub

    }

    @Override
    public void resume() {
    // TODO Auto-generated method stub

    }

    @Override
    public void dispose() {
    // TODO Auto-generated method stub

    }
}
0

All Articles