Ich versuche, einen Akteur zu animieren, der eine einfache Nachricht enthält, die mit bitmapfont mit der Funktion fadeIn geschrieben wurde, aber es funktioniert nicht.BitmapFont Animation in Libgdx scene2d Darsteller
Hier ist mein Code.
public class Message extends Actor{
BitmapFont font;
String message;
float x, y;
public Message(BitmapFont font, String message, float x, float y) {
this.font = font;
this.message = message;
this.x = x;
this.y = y;
}
@Override
public void draw(Batch batch, float parentAlpha) {
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
font.setColor(color.r, color.g, color.b, color.a * parentAlpha);
font.draw(batch, message, x, y);
}
}
Dann sollte beim Klicken auf eine Schaltfläche die Nachricht angezeigt werden, aber es wird nur ohne Animation angezeigt
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
BitmapFont font = new BitmapFont(Gdx.files.internal("myfont.font"));
Message message = new Message(font, "Tap Here", 100, 20);
stage.addActor(message);
message.addAction(Actions.fadeIn(5));
}});
Andere Akteure Animationen auf der gleichen Bühne funktionieren wie ich rufe:
stage.act(delta);
stage.draw();
* * fadeIn **> Übergänge vom Alpha zum Zeitpunkt, an dem diese Aktion beginnt (bereits 1) bis zu einem Alpha von 1, also ohne Animation erscheinen – Aryan
ein Tipp, der ein neues Bitmapfont-Objekt erstellt, ist keine gute Lösung, also bitte Vorsicht. – Aryan