Example usage for com.badlogic.gdx.scenes.scene2d Action Action

List of usage examples for com.badlogic.gdx.scenes.scene2d Action Action

Introduction

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

Prototype

Action

Source Link

Usage

From source file:com.ahsgaming.valleyofbones.screens.SplashScreen.java

License:Apache License

@Override
public void resize(int width, int height) {
    super.resize(width, height);

    stage.addActor(splashImage);//from   w  ww .ja va  2s.  co  m
    splashImage.setPosition((stage.getWidth() - splashImage.getWidth()) * 0.5f,
            (stage.getHeight() - splashImage.getHeight()) * 0.5f);
    splashImage.setColor(1, 1, 1, 0);
    splashImage.addAction(
            Actions.sequence(Actions.fadeIn(1.5f), Actions.delay(1.0f), Actions.fadeOut(1.5f), new Action() {
                public boolean act(float delta) {
                    game.setScreen(game.getMainMenuScreen());
                    return true;
                }
            }));

}

From source file:com.axatrikx.solor.view.SplashScreen.java

License:Apache License

@Override
public void show() {
    super.show();

    // start playing the menu music
    // game.getMusicManager().play(SolorMusic.MENU);

    TextureRegion splashRegion = new TextureRegion(new Texture("images/splash.png"), 0, 0, 512, 301);
    Drawable splashDrawable = new TextureRegionDrawable(splashRegion);

    // here we create the splash image actor; its size is set when the
    // resize() method gets called
    splashImage = new Image(splashDrawable, Scaling.stretch);
    splashImage.setFillParent(true);//w w w.  ja v  a  2s  .  c o  m

    // this is needed for the fade-in effect to work correctly; we're just
    // making the image completely transparent
    splashImage.getColor().a = 0f;

    // configure the fade-in/out effect on the splash image
    splashImage.addAction(sequence(fadeIn(0.75f), delay(1.75f, fadeOut(0.75f)), new Action() {
        @Override
        public boolean act(float delta) {
            // the last action will move to the next screen
            game.setScreen(game.getMenuScreen());
            return true;
        }
    }));

    // and finally we add the actor to the stage
    stage.addActor(splashImage);
}

From source file:com.bagon.matchteam.mtx.game.AbstractGame.java

License:Apache License

/**
 * BETA method (Works fine, but need lots of test) <br>
 * Screen to screen transition, only works for Scene2D Stage based game,
 * actionCurrent is applied to current stage when it is completed
 * (Sequence), actionNext is applied to new screens stage as intro for next
 * screen// ww  w  . jav  a 2s . com
 * <p>
 * 
 * WARNING! Do not use dispose anywhere else for stage/screen, if dispose
 * true here
 * 
 * @param currentScreen
 *            the screen currently set
 * @param actionCurrent
 *            Scene2D action to be applied to current screen stage
 * @param nextScreen
 *            the next screen to be set
 * @param actionNext
 *            Scene2D action to be applied to next screen stage
 * @param disposeScreen
 *            dispose current screen after transition completed
 * */
public void setScreenWithTransition(final AbstractScreen currentScreen, final Action actionCurrent,
        final AbstractScreen nextScreen, final Action actionNext, final boolean disposeScreen) {
    //
    currentScreen.getStage().getRoot().setTouchable(Touchable.disabled);
    nextScreen.getStage().getRoot().setTouchable(Touchable.disabled);
    //
    previousScreenToDispose = currentScreen;
    if (actionCurrent != null && currentScreen != null) {
        currentScreen.getStage().addAction(Actions.sequence(actionCurrent, new Action() {
            @Override
            public boolean act(float delta) {
                if (actionNext != null) {
                    setScreen(nextScreen);
                    nextScreen.getStage().addAction(actionNext);
                    nextScreen.getStage().getRoot().setTouchable(Touchable.enabled);
                    isDisposeScreen = disposeScreen;
                } else {
                    setScreen(nextScreen);
                    nextScreen.getStage().getRoot().setTouchable(Touchable.enabled);
                    isDisposeScreen = disposeScreen;
                }
                return true;
            }
        }));
    } else {
        if (actionNext != null) {
            setScreen(nextScreen);
            nextScreen.getStage().getRoot().setTouchable(Touchable.enabled);
            nextScreen.getStage().addAction(actionNext);
            isDisposeScreen = disposeScreen;
        } else {
            setScreen(nextScreen);
            nextScreen.getStage().getRoot().setTouchable(Touchable.enabled);
            isDisposeScreen = disposeScreen;
        }
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Scale effect (SC)//from w w w .j  a  va 2 s  .c  o m
 * */
public static void create_SC(Actor actor, float scaleRatioX, float scaleRatioY, float duration,
        final Group group, final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.scaleTo(scaleRatioX, scaleRatioY, duration), new Action() {
            @Override
            public boolean act(float delta) {
                if (removeActor) {
                    removeActor(group, actor);
                    return false;
                } else {
                    return true;
                }
            }
        }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Fade Out (FO)//from   w w w  .  jav  a 2 s.  c o  m
 * */
public static void create_FO(Actor actor, float duration, float delay, final Group group,
        final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.delay(delay), Actions.fadeOut(duration), new Action() {
            @Override
            public boolean act(float delta) {
                if (removeActor) {
                    removeActor(group, actor);
                    return false;
                } else {
                    return true;
                }
            }
        }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Fade In (FI)//from ww  w .  ja v a2  s .c  o m
 * */
public static void create_FI(Actor actor, float duration, float delay, final Group group,
        final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.delay(delay), Actions.fadeIn(duration), new Action() {
            @Override
            public boolean act(float delta) {
                if (removeActor) {
                    removeActor(group, actor);
                    return false;
                } else {
                    return true;
                }
            }
        }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Move to a position/* w  w  w. j  a va  2 s.  c om*/
 * */
public static void create_MT(Actor actor, float duration, float delayBefore, float posX, float posY,
        final Group group, final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.delay(delayBefore), Actions.moveTo(posX, posY, duration),
                new Action() {
                    @Override
                    public boolean act(float delta) {
                        if (removeActor) {
                            removeActor(group, actor);
                            return false;
                        } else {
                            return true;
                        }
                    }
                }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Shake effect (SHK)/* ww  w . j a v  a2 s. c o m*/
 * */
public static void create_SHK(Actor actor, float shakeAngle, float originalAngle, float duration,
        final Group group, final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.rotateTo(shakeAngle, duration),
                Actions.rotateTo(-shakeAngle, duration), Actions.rotateTo(originalAngle, duration),
                new Action() {
                    @Override
                    public boolean act(float delta) {
                        if (removeActor) {
                            removeActor(group, actor);
                            return false;
                        } else {
                            return true;
                        }
                    }
                }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Scale effect and Back to previous scale (SC, BTN)
 * *//*  w ww  .j a v  a  2  s.c o m*/
public static void create_SC_BTN(Actor actor, float scaleRatioX, float scaleRatioY, float duration,
        final Group group, final boolean removeActor) {
    if (actor != null) {
        float originalScaleX = actor.getScaleX();
        float originalScaleY = actor.getScaleY();
        actor.addAction(Actions.sequence(Actions.scaleTo(scaleRatioX, scaleRatioY, duration),
                Actions.scaleTo(originalScaleX, originalScaleY, duration), new Action() {
                    @Override
                    public boolean act(float delta) {
                        if (removeActor) {
                            removeActor(group, actor);
                            return false;
                        } else {
                            return true;
                        }
                    }
                }));
    }
}

From source file:com.bagon.matchteam.mtx.scene2d.effects.EffectCreator.java

License:Apache License

/**
 * Scale effect and Back to original (1.0f)
 * *//*from w  ww  . j a  v a2s.c om*/
public static void create_SC_BTO(Actor actor, float scaleRatioX, float scaleRatioY, float duration,
        final Group group, final boolean removeActor) {
    if (actor != null) {
        actor.addAction(Actions.sequence(Actions.scaleTo(scaleRatioX, scaleRatioY, duration),
                Actions.scaleTo(1.0f, 1.0f, duration), new Action() {
                    @Override
                    public boolean act(float delta) {
                        if (removeActor) {
                            removeActor(group, actor);
                            return false;
                        } else {
                            return true;
                        }
                    }
                }));
    }
}