Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AnimatedTexture animation is accelerated when the application is started for the first time #1380

Open
starxg opened this issue Jul 23, 2024 · 3 comments

Comments

@starxg
Copy link

starxg commented Jul 23, 2024

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

7.23.mov

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);
        }
    }
}

sunflower-images.zip

@AlmasB
Copy link
Owner

AlmasB commented Jul 27, 2024

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.

@starxg
Copy link
Author

starxg commented Aug 6, 2024

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?

@DeathPhoenix22
Copy link
Contributor

Hi Starxg,
This will fix the issue: #1298
Hope it helps

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants