简体   繁体   中英

Introduce delay in libgdx Animation

I am using libgdx on a little game and I have a little animation on my menu screen. I have used Animation() class and gave it a list of 20 sprites. The animation duration is 2 seconds. What I want is to make this animation repeat each 4 seconds. So I need a way to introduce delay between repetitions.

I'm not sure if the Animation class has native support for delays like this, but you can always just keep track of elapsed time yourself and restart the animation after the elapsed time passes 4 seconds. For details see: https://gamedev.stackexchange.com/questions/25001/waiting-specific-time-to-increase-sound-libgdx

You can always try the delay() action from the

import static com.badlogic.gdx.scenes.scene2d.actions.Actions.delay;

here's how I use it internally in an Actor class, together with some other actions. They're pretty cool and low on memory usage.

this.addAction(sequence(moveBy(0, 10, 0.1f), moveBy(0, -10, 0.1f),delay(0.75f),run(
            new Runnable(){
                public void run () {
                    Gdx.app.log("NOTICE", " Notice deleted!");     
                    disappear();
            }})));  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM