I’m trying to implement a simple “counting numbers” animation in my game. I want that whenever the score is changed, the numbers will start to count up/down until they have reached the desired number.
I tried to implement this by doing this:
points = new Label(""+ScoreManager.getPlayerScore(), skin, "default-nice") {
private float target, rendered;
public void act(float delta) {
super.act(delta);
target = ScoreManager.getPlayerScore();
rendered = rendered < target ? Interpolation.linear.apply(rendered, target, 0.05f) : Interpolation.linear.apply(target, rendered, 0.05f);
setText("" + MathUtils.ceil(target));
}
};
But it has no affect. The numbers are still changed suddently.
P.S I have one more question, not related to this topic - How can I define a fixed position to a table? I set a position for a table in my game but it can changed according to its children’s width and height.