I'm trying to create a Minecraft like quotes on the menu screen of my game.
I'm using BitmapFont
to draw the text on screen but I don't know how to make that scale up scale down effect.
This is what I tried to do.
public class MenuQuotes extends Actor {
private BitmapFont font16;
private String str;
public MenuQuotes() {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/minecraft.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 16;
parameter.color = Color.WHITE;
parameter.shadowColor = Color.BLACK;
parameter.shadowOffsetX = 1;
parameter.shadowOffsetY = 1;
font16 = generator.generateFont(parameter);
generator.dispose();
}
@Override
public void draw(Batch batch, float alpha) {
super.draw(batch, alpha);
ScaleToAction scaleAction = new ScaleToAction();
scaleAction.setScale(10, 10);
scaleAction.setDuration(10);
GlyphLayout glyphLayout = new GlyphLayout();
str = "Chickens are the closest relative\nto Tyrannosaurus";
glyphLayout.setText(font16, str);
float w = glyphLayout.width;
font16.draw(batch, str, (Chicken.V_WIDTH / 2) / 2 - w / 2, (Chicken.V_HEIGHT / 2) / 2 + 10);
this.addAction(scaleAction);
}
@Override
public void act(float delta) {
super.act(delta);
}
}