adds font

This commit is contained in:
Rosia E Evans 2024-04-21 15:52:11 +01:00
parent 97639fca47
commit 605d81d35e
3 changed files with 13 additions and 4 deletions

Binary file not shown.

View file

@ -47,7 +47,8 @@ project(":desktop") {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
@ -57,6 +58,7 @@ project(":core") {
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
}
}

View file

@ -6,6 +6,7 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.ScreenUtils;
import com.monjaro.gamejam.SegmentUI;
@ -35,8 +36,6 @@ public class Game extends ApplicationAdapter {
@Override
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
font.getData().markupEnabled = true;
img = new Texture("badlogic.jpg");
segUi = new SegmentUI(new Rectangle(0, (Gdx.graphics.getHeight()/3)*2, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/3));
@ -52,6 +51,14 @@ public class Game extends ApplicationAdapter {
SegmentUI.setCriteriaSheet(new Texture("criteria.png"));
// SegmentUI.setCriteriaSheet(""); not made yet
// setting up font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/single_day_regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 12;
font = generator.generateFont(parameter); // font size 12 pixels
generator.dispose(); // don't forget to dispose to avoid memory leaks!
font.getData().markupEnabled = true;
float divide = Gdx.graphics.getWidth() / 6f;
for (int i = 0; i < 5; i++) {
dice.add(new Die(divide * (i + 1), 350, 64, 64));