Java 类com.badlogic.gdx.scenes.scene2d.actions.TemporalAction 实例源码

项目:dice-heroes    文件:SoundManager.java   
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);
}
项目:dice-heroes    文件:SoundManager.java   
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);
}
项目:dice-heroes    文件:AnimationHelper.java   
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)));
        }
    });
}
项目:spezi-gdx    文件:Animations.java   
public static TemporalAction interpolate(TemporalAction action,
        Interpolation interpolation) {
    action.setInterpolation(interpolation);
    return action;
}