Example usage for com.badlogic.gdx.math Interpolation fade

List of usage examples for com.badlogic.gdx.math Interpolation fade

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Interpolation fade.

Prototype

Interpolation fade

To view the source code for com.badlogic.gdx.math Interpolation fade.

Click Source Link

Usage

From source file:broken.shotgun.throwthemoon.actors.Enemy.java

License:Open Source License

public void die() {
    addAction(sequence(fadeOut(0.4f, Interpolation.fade), removeActor()));
}

From source file:broken.shotgun.throwthemoon.actors.Moon.java

License:Open Source License

public void startFalling() {
    if (falling)/*from   w  w w .  j av  a  2s . c o m*/
        return;

    falling = true;
    distance = 0;

    crashSfx.play(1.0f, 0.5f, 0f);

    addAction(Actions.moveBy(10, -getHeight(), 10f, Interpolation.fade));
}

From source file:broken.shotgun.throwthemoon.actors.MoonChain.java

License:Open Source License

public void detachTail() {
    attachedPlayer = null;
    addAction(Actions.moveTo(-50, getY(), 12f, Interpolation.fade));
}

From source file:broken.shotgun.throwthemoon.stages.GameStage.java

License:Open Source License

public void spawnEnemies(List<EnemySpawn> spawnList) {
    int offsetY = 100;
    for (EnemySpawn spawn : spawnList) {
        if (spawn.enemyId == 0) {
            Enemy newEnemy = new Enemy(manager);
            Vector2 spawnPoint = new Vector2();
            spawnPoint.y = offsetY + (getViewport().getScreenHeight() / spawnList.size());
            switch (spawn.location) {
            case FRONT:
                spawnPoint.x = getViewport().getScreenWidth() * 0.8f;
                break;
            case BACK:
                spawnPoint.x = getViewport().getScreenWidth() * 0.15f;
                break;
            }//from   w ww .  j a v a 2  s. c  o m

            screenToStageCoordinates(spawnPoint);
            newEnemy.setPosition(spawnPoint.x, spawnPoint.y + (newEnemy.getHeight() / 2));
            newEnemy.setColor(1.0f, 1.0f, 1.0f, 0.0f);
            newEnemy.addAction(Actions.fadeIn(0.5f));
            addActor(newEnemy);
            offsetY += (getViewport().getScreenHeight() / spawnList.size());
        } else if (spawn.enemyId == 100) {
            boss = new Boss(manager);
            Vector2 spawnPoint = new Vector2();
            spawnPoint.y = (getViewport().getScreenHeight() / 2);
            switch (spawn.location) {
            case FRONT:
                spawnPoint.x = getViewport().getScreenWidth() * 0.7f;
                break;
            case BACK:
                spawnPoint.x = getViewport().getScreenWidth() * 0.15f;
                break;
            }

            screenToStageCoordinates(spawnPoint);
            boss.setPosition(spawnPoint.x + (getViewport().getScreenWidth() * 0.5f),
                    spawnPoint.y - (boss.getHeight() / 2));
            boss.addAction(Actions.sequence(
                    Actions.moveTo(spawnPoint.x, spawnPoint.y - (boss.getHeight() / 2), 3f, Interpolation.fade),
                    Actions.run(new Runnable() {
                        @Override
                        public void run() {
                            boss.startBattle();
                        }
                    })));
            addActor(boss);
            player.enableMoonThrow();
            chain.hintPullChain();
        }
    }
}

From source file:com.aia.hichef.ui.n.MyDialog.java

License:Apache License

/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */
public MyDialog show(Stage stage) {
    clearActions();/*from ww w .j av  a2 s.c  om*/
    removeCaptureListener(ignoreTouchDown);

    previousKeyboardFocus = null;
    Actor actor = stage.getKeyboardFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousKeyboardFocus = actor;

    previousScrollFocus = null;
    actor = stage.getScrollFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousScrollFocus = actor;

    pack();
    setPosition(Math.round((stage.getWidth() - getWidth()) / 2),
            Math.round((stage.getHeight() - getHeight()) / 2));
    stage.addActor(this);
    stage.setKeyboardFocus(this);
    stage.setScrollFocus(this);
    if (fadeDuration > 0) {
        getColor().a = 0;
        addAction(Actions.fadeIn(fadeDuration, Interpolation.fade));
    }
    return this;
}

From source file:com.aia.hichef.ui.n.MyDialog.java

License:Apache License

/**
 * Hides the dialog. Called automatically when a button is clicked. The
 * default implementation fades out the dialog over {@link #fadeDuration}
 * seconds and then removes it from the stage.
 *//*from   www.j av  a2 s  .c  o  m*/
public void hide() {
    Stage stage = getStage();
    if (stage != null) {
        if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null)
            previousKeyboardFocus = null;
        Actor actor = stage.getKeyboardFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setKeyboardFocus(previousKeyboardFocus);

        if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
            previousScrollFocus = null;
        actor = stage.getScrollFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setScrollFocus(previousScrollFocus);
    }
    if (fadeDuration > 0) {
        addCaptureListener(ignoreTouchDown);
        addAction(sequence(fadeOut(fadeDuration, Interpolation.fade),
                Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
    } else
        remove();
}

From source file:com.alterego.jelly.screens.PlayGameScreen.java

License:Apache License

private void rebuildStage() {
    buttonPause = new JellyButton(Assets.instance.gameElements.pause);
    buttonPause.setMyScaleSize(1.3f, 1.3f);
    buttonPause.setPosition(8, Const.GAME_HEIGHT - buttonPause.getHeight() - 8);
    buttonPause.addTouchListener(new RunnableAction() {
        public void run() {
            pauseUi.showWindow(true);/*from  w w  w  .  java  2s .c o  m*/
        }
    }, null);

    buttonReplay = new JellyButton(Assets.instance.gameElements.replay);
    buttonReplay.setMyScaleSize(1.3f, 1.3f);
    buttonReplay.setPosition(8, Const.GAME_HEIGHT - 2 * buttonReplay.getHeight() - 15);
    buttonReplay.addTouchListener(new RunnableAction() {
        public void run() {
            winnerUi.showWindow(true);
            winnerUi.setTime(110);
        }
    }, null);

    Label.LabelStyle labelStyle = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE);
    gameTime = new Label("0:00", labelStyle);
    gameTime.setAlignment(Align.left);
    gameTime.setPosition(Const.GAME_WIDTH - 135, Const.GAME_HEIGHT - 60);
    gameTime.setWrap(true);
    gameTime.setWidth(350f);

    star = new Image(Assets.instance.gameElements.star);
    star.setScale(0.3f);
    star.setOrigin(star.getWidth() / 2, star.getHeight() / 2);
    star.addAction(Actions.alpha(0f));
    star1 = new Image(Assets.instance.gameElements.star);
    star1.setScale(0.3f);
    star1.setPosition(Const.GAME_WIDTH - 60, Const.GAME_HEIGHT - 92);
    star2 = new Image(Assets.instance.gameElements.star);
    star2.setScale(0.3f);
    star2.setPosition(star1.getX() - 40, Const.GAME_HEIGHT - 92);
    star3 = new Image(Assets.instance.gameElements.star);
    star3.setScale(0.3f);
    star3.setPosition(star2.getX() - 40, Const.GAME_HEIGHT - 92);

    Label.LabelStyle labelStyle2 = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE);
    freezes = new Label("0", labelStyle2);
    freezes.setText(String.valueOf(LevelData.freezers));
    freezes.setAlignment(Align.right);
    freezes.setPosition(Const.GAME_WIDTH - 200, Const.GAME_HEIGHT - 170);
    freezes.setWrap(true);
    freezes.setWidth(100f);

    freezeFon = new Image(Assets.instance.gameElements.freezeBuyFon);
    freezeFon.setPosition(Const.GAME_WIDTH - 158, Const.GAME_HEIGHT - buttonReplay.getHeight() - 107);
    freezeFon.setScale(0.6f);

    buttonBuyFreeze = new JellyButton(Assets.instance.gameElements.freezeBuy);
    buttonBuyFreeze.setMyScaleSize(1.6f, 1.6f);
    buttonBuyFreeze.setPosition(Const.GAME_WIDTH - buttonBuyFreeze.getWidth() - 15,
            Const.GAME_HEIGHT - buttonReplay.getHeight() - 100);
    buttonBuyFreeze.addTouchListener(new RunnableAction() {
        public void run() {
            marketUi.showWindow(true);
        }
    }, null);

    imgFreeze = new Image(Assets.instance.gameElements.freeze);
    imgFreeze.setOrigin(imgFreeze.getWidth() / 2, imgFreeze.getHeight() / 2);
    imgFreeze.setScale(0.7f);
    imgFreeze.setPosition(freezeFon.getX() - 17, freezeFon.getY() - 25);
    imgFreeze.addAction(Actions.alpha(0f));

    if (addHelp) {
        float delay = 5f;
        if (GamePreferences.instance.isSensorXYZ) {
            delay = 4f;
            helpNavigate = new Image(Assets.instance.menuElements.navigate_tel);
            helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2);
            helpNavigate.setScale(0.7f);
            helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500);
            helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() {
                public void run() {
                    gameState = GameState.PAUSE;
                }
            }, Actions.alpha(1f, 0.5f), Actions.rotateBy(15f, 0.4f, Interpolation.fade),
                    Actions.rotateBy(-30f, 0.8f, Interpolation.fade),
                    Actions.rotateBy(25f, 0.7f, Interpolation.fade), Actions.alpha(0f, 0.4f)));
        } else {
            helpNavigate = new Image(Assets.instance.menuElements.navigate_finger);
            helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2);
            helpNavigate.setScale(0.7f);
            helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500);
            helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() {
                public void run() {
                    gameState = GameState.PAUSE;
                }
            }, Actions.alpha(1f, 0.5f), Actions.moveBy(-150f, 0, 0.7f, Interpolation.fade),
                    Actions.moveBy(80f, 0, 0.7f, Interpolation.fade),
                    Actions.moveBy(0, 150f, 0.7f, Interpolation.fade),
                    Actions.moveBy(0, -200f, 0.7f, Interpolation.linear), Actions.alpha(0f, 0.4f)));
        }
        helpFreeze = new Image(Assets.instance.menuElements.navigate_finger);
        helpFreeze.setOrigin(helpFreeze.getWidth() / 2, helpFreeze.getHeight() / 2);
        helpFreeze.setScale(-0.7f, 0.7f);
        helpFreeze.setPosition(helpFreeze.getWidth() + 35, Const.GAME_HEIGHT - 500);
        helpFreeze.addAction(sequence(Actions.alpha(0f), Actions.delay(delay), Actions.alpha(1f, 0.5f),
                Actions.moveBy(LevelData.posX - helpFreeze.getX() + 20,
                        LevelData.posY - helpFreeze.getY() - helpFreeze.getHeight() - 28, 0.7f,
                        Interpolation.fade),
                new RunnableAction() {
                    public void run() {
                        setAnimation(animFreezeOn);
                    }
                }, Actions.alpha(0f, 0.2f)));
    }

    if (addHelp) {
        stage.addActor(helpNavigate);
        stage.addActor(helpFreeze);
    }
    stage.addActor(buttonPause);
    stage.addActor(buttonReplay);
    stage.addActor(gameTime);
    stage.addActor(freezeFon);
    stage.addActor(freezes);
    stage.addActor(buttonBuyFreeze);
    stage.addActor(star1);
    stage.addActor(star2);
    stage.addActor(star3);
    stage.addActor(star);
    stage.addActor(imgFreeze);
    stage.addActor(levelBuilder);
    stage.addActor(winnerUi);
    stage.addActor(marketUi);
    stage.addActor(pauseUi);

}

From source file:com.anstrat.gui.SnapScrollPane.java

License:Apache License

@Override
public void draw(SpriteBatch batch, float parentAlpha) {
    if (widget == null)
        return;//from w  w w.  j  a v a 2 s .  c om

    validate();

    // Setup transform for this group.
    applyTransform(batch, computeTransform());

    if (scrollX)
        hKnobBounds.x = hScrollBounds.x
                + (int) ((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX());
    if (scrollY)
        vKnobBounds.y = vScrollBounds.y
                + (int) ((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY()));

    // Calculate the widget's position depending on the scroll state and available widget area.
    float y = widgetAreaBounds.y;
    if (!scrollY)
        y -= (int) maxY;
    else
        y -= (int) (maxY - visualAmountY);

    if (scrollbarsOnTop && scrollX) {
        float scrollbarHeight = 0;
        if (style.hScrollKnob != null)
            scrollbarHeight = style.hScrollKnob.getMinHeight();
        if (style.hScroll != null)
            scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight());
        y += scrollbarHeight;
    }

    float x = widgetAreaBounds.x;
    if (scrollX)
        x -= (int) visualAmountX;
    widget.setPosition(x, y);

    if (widget instanceof Cullable) {
        widgetCullingArea.x = -widget.getX() + widgetAreaBounds.x;
        widgetCullingArea.y = -widget.getY() + widgetAreaBounds.y;
        widgetCullingArea.width = widgetAreaBounds.width;
        widgetCullingArea.height = widgetAreaBounds.height;
        ((Cullable) widget).setCullingArea(widgetCullingArea);
    }

    // Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
    // project those to screen coordinates for OpenGL ES to consume.
    ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), widgetAreaBounds,
            scissorBounds);

    // Draw the background ninepatch.
    Color color = getColor();
    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    if (style.background != null)
        style.background.draw(batch, 0, 0, getWidth(), getHeight());
    batch.flush();

    // Enable scissors for widget area and draw the widget.
    if (ScissorStack.pushScissors(scissorBounds)) {
        drawChildren(batch, parentAlpha);
        ScissorStack.popScissors();
    }

    // Render scrollbars and knobs on top.
    batch.setColor(color.r, color.g, color.b,
            color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds));
    if (scrollX && scrollY) {
        if (style.corner != null) {
            style.corner.draw(batch, hScrollBounds.x + hScrollBounds.width, hScrollBounds.y,
                    vScrollBounds.width, vScrollBounds.y);
        }
    }
    if (scrollX) {
        if (style.hScroll != null)
            style.hScroll.draw(batch, hScrollBounds.x, hScrollBounds.y, hScrollBounds.width,
                    hScrollBounds.height);
        if (style.hScrollKnob != null)
            style.hScrollKnob.draw(batch, hKnobBounds.x, hKnobBounds.y, hKnobBounds.width, hKnobBounds.height);
    }
    if (scrollY) {
        if (style.vScroll != null)
            style.vScroll.draw(batch, vScrollBounds.x, vScrollBounds.y, vScrollBounds.width,
                    vScrollBounds.height);
        if (style.vScrollKnob != null)
            style.vScrollKnob.draw(batch, vKnobBounds.x, vKnobBounds.y, vKnobBounds.width, vKnobBounds.height);
    }

    resetTransform(batch);
}

From source file:com.bladecoder.engineeditor.ui.components.EditableSelectBox.java

License:Apache License

protected void onShow(Actor selectBoxList, boolean below) {
    selectBoxList.getColor().a = 0;
    selectBoxList.addAction(fadeIn(0.3f, Interpolation.fade));
}

From source file:com.bladecoder.engineeditor.utils.Message.java

License:Apache License

public static void showMsg(Stage stage, String text, boolean modal) {
    isModal = modal;/* w  w w.  j a va2 s  . co  m*/

    if (text == null) {
        hideMsg();
        return;
    }

    add(stage, text);

    if (FADE_DURATION > 0) {
        msg.getColor().a = 0;
        msg.addAction(Actions.fadeIn(FADE_DURATION, Interpolation.fade));
    }
}