AnimatedTexture animation is accelerated when the application is started for the first time
Describe the bug AnimationChannel and AnimatedTexture speed inconsistencies
Expected behavior When I initially start it up, there seems to be a speeding up of the frame rate. This problem goes away when the programme runs for 2-3 seconds.
Screenshots
https://github.com/user-attachments/assets/986b98ca-2b66-40db-8143-73c95c8c2f49
Runtime info(please complete the following information): FXGL-21.1 (27.03.2024 07.52) on MAC M3 (J:21.0.3 FX:21.0.1)
Additional context / possible fixes
@Override
protected void initSettings(GameSettings settings) {
}
@Override
protected void initGame() {
final Sunflower3 sunflower = new Sunflower3();
sunflower.setX(200);
sunflower.setY(200);
FXGL.getGameWorld().addEntity(sunflower);
}
public static void main(String[] args) {
launch(args);
}
public class Sunflower3 extends Entity {
public Sunflower3() {
addComponent(new SunflowerComponent());
}
private static class SunflowerComponent extends Component {
private final AnimatedTexture texture;
private SunflowerComponent() {
List<Image> images = new ArrayList<>(24);
for (int i = 1; i <= 24; i++) {
images.add(FXGL.image("plant/sunflower/SunFlower" + StringUtils.leftPad(String.valueOf(i), 4, '0') + ".png"));
}
final AnimationChannel ac = new AnimationChannel(images, Duration.seconds(2));
texture = new AnimatedTexture(ac);
texture.loop();
}
@Override
public void onAdded() {
getEntity().getViewComponent().addChild(texture);
}
}
}
Hi, thanks for this. It's likely caused by the engine incorrectly calculating tpf / fps at the start. There is an open PR which should fix it in the future releases.
Hi, thanks for this. It's likely caused by the engine incorrectly calculating tpf / fps at the start. There is an open PR which should fix it in the future releases.
Thank you for your reply. Are there any plans for a release?
Hi Starxg, This will fix the issue: https://github.com/AlmasB/FXGL/pull/1298 Hope it helps