0
votes

I want to add text on the top of the enemies body.

Downscale issue starts here:

https://gamedev.stackexchange.com/questions/73688/why-is-my-text-is-too-large-even-when-scaled-to-05f-in-libgdx

The issue is that the text is very very big and i can't scale it smaller. There is a solution for this, to add another camera / viewport. This is OK - for HUD screen.

But i need the text on the enemy head.

From font class:

viewport = new FitViewport(Application.V_WIDTH * 4 , Application.V_HEIGHT * 4, new OrthographicCamera());
stage = new Stage(viewport, SpriteBatch);
stage.addActor(tableText);

Game main class:

viewport = new FitViewport(Application.V_WIDTH / Application.PPM, Application.V_HEIGHT / Application.PPM, orthographicCamera);
AND THE GAME. . .

What should i do? Do i need to find the right ratio betwin the game and the font class?

Danke

1
I don't see the problem > But i need the text on the enemy head. You can use 1 camera for the enemies and 1 for the text on their heads and the rest of the HUD - Cedric Martens
Thanks for the replay, so how would you get the same x and y? (of the enemy) - Nimitack
I believe Camera.unproject can do this. - Cedric Martens
I don't understand, should i add 2 cameras ? how should i implement this? - Nimitack
Yes, you want to use 2 cameras. - Cedric Martens

1 Answers

-1
votes

There is another way that works for me now:

    bitmapFont.getData().setScale(0.008f);
    bitmapFont.setUseIntegerPositions(false);

From libgdx API:

/** Specifies whether to use integer positions. Default is to use them so filtering doesn't kick in as badly. */
public void setUseIntegerPositions (boolean integer) {
    this.integer = integer;
    cache.setUseIntegerPositions(integer);
}