Example usage for com.badlogic.gdx.scenes.scene2d Stage addAction

List of usage examples for com.badlogic.gdx.scenes.scene2d Stage addAction

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Stage addAction.

Prototype

public void addAction(Action action) 

Source Link

Document

Adds an action to the root of the stage.

Usage

From source file:com.vlaaad.dice.game.tutorial.tasks.Delay.java

License:Open Source License

@Override
public void start(final Callback callback) {
    final Stage stage = resources.get("stage");
    stage.addAction(Actions.delay(duration, Actions.run(new Runnable() {
        @Override/*from w  w  w  .j  a  va2 s .  co  m*/
        public void run() {
            callback.taskEnded();
        }
    })));
}

From source file:com.vlaaad.dice.managers.SoundManager.java

License:Open Source License

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;/*ww w.j  a  v a2  s. co  m*/
    }
    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);
}

From source file:com.vlaaad.dice.managers.SoundManager.java

License:Open Source License

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;//from  w w  w.  j a v a2s .c  om
    }
    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);
}