com.badlogic.gdx.scenes.scene2d.actions.TemporalAction Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.actions.TemporalAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoundManager.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public void playMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(0);
    if (!usesMusic) {
        disabledMusics.add(music);
    } else {
        music.play();
    }
    music.setLooping(true);
    playingMusics.add(music);
    Action action = new TemporalAction(5f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(percent * volume);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
Example #2
Source File: SoundManager.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public void stopMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    final float initialVolume = music.getVolume();
    Action action = new TemporalAction(2f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(initialVolume - percent * initialVolume);
        }

        @Override protected void end() {
            music.stop();
            playingMusics.remove(music);
            disabledMusics.remove(music);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
Example #3
Source File: AnimationHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void animateCounter(final Label label, final int from, final int to) {
    label.addAction(new TemporalAction(MathUtils.clamp(Math.abs(to - from) / 30f, 0.5f, 1.5f), new Interpolation.ExpOut(2, 3)) {
        @Override protected void update(float percent) {
            label.setText(String.valueOf((int) (from + (to - from) * percent)));
        }
    });
}
 
Example #4
Source File: PageGroup.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
private void startPageAppearAnimation() {
    addAction(new TemporalAction(0.15f) {
        @Override
        protected void update(float percent) {
            pageAlpha = percent;
        }
    });
}