本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.actions.TemporalAction类的典型用法代码示例。如果您正苦于以下问题:Java TemporalAction类的具体用法?Java TemporalAction怎么用?Java TemporalAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemporalAction类属于com.badlogic.gdx.scenes.scene2d.actions包,在下文中一共展示了TemporalAction类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playMusicBeautifully
import com.badlogic.gdx.scenes.scene2d.actions.TemporalAction; //导入依赖的package包/类
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);
}
示例2: stopMusicBeautifully
import com.badlogic.gdx.scenes.scene2d.actions.TemporalAction; //导入依赖的package包/类
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);
}
示例3: animateCounter
import com.badlogic.gdx.scenes.scene2d.actions.TemporalAction; //导入依赖的package包/类
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)));
}
});
}
示例4: interpolate
import com.badlogic.gdx.scenes.scene2d.actions.TemporalAction; //导入依赖的package包/类
public static TemporalAction interpolate(TemporalAction action,
Interpolation interpolation) {
action.setInterpolation(interpolation);
return action;
}