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

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

Introduction

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

Prototype

PowOut pow2Out

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

Click Source Link

Usage

From source file:com.agateau.pixelwheels.sound.EngineSoundPlayer.java

License:Open Source License

public void play(float speed, float maxVolume) {
    mPitch = Interpolation.pow2Out.apply(MIN_PITCH, MAX_PITCH, speed);
    float idx = speed * (mSoundPlayers.size - 1);
    for (int i = 0; i < mSoundPlayers.size; ++i) {
        float di = Math.abs(i - idx);
        float volume = Math.max(1 - di, 0) * maxVolume;
        SoundPlayer player = mSoundPlayers.get(i);
        player.setVolume(volume);/* w  w w  . j  av  a  2s .  co  m*/
        player.setPitch(mPitch);
        if (volume > 0.01) {
            if (!player.isLooping()) {
                player.loop();
            }
        } else {
            player.stop();
        }
    }
}

From source file:com.centergame.starttrack.graphics.actors.TabView.java

/**
 * Called when tab gets selected, after {@link #onTabUnselected}.
 * @param index index of selected tab/*from w  ww  .j  a va 2 s  . c  om*/
 * @param header tab's header
 * @param content tab's content
 */
public void onTabSelected(int index, Text header, Group content) {
    header.getStyle().fontColor = selectedTextColor;
    header.setStyle(header.getStyle());

    underline.addAction(Actions.parallel(Actions.moveTo(
            //                  header.getX() + header.getWidth() / 2 - header.getGlyphLayout().width / 2 - underlinePadding,
            header.getX(), headerHeight, 0.4f, Interpolation.pow2Out),
            Actions.sizeTo(
                    //header.getGlyphLayout().width + 2 * underlinePadding,
                    header.getWidth(), underline.getHeight(), 0.4f, Interpolation.pow2Out)));
}

From source file:com.cyphercove.dayinspace.MusicManager.java

License:Apache License

public void update(float delta) {
    if (music1 != null) {
        if (fading) {
            fadeTime += delta;/*from w  w  w  .  j av a2s.com*/
            if (fadeTime > FADE_DURATION) {
                fading = false;
                stop(false);
                return;
            }
            float fadeAlpha = 1f - Interpolation.pow2Out.apply(fadeTime / FADE_DURATION);
            music1.setVolume(fadeAlpha);
        } else {
            music1.setVolume(1f);
        }
    }

    //cross fade
    if (nextTrack != null) {
        crossFadeTime += delta;
        float fadeAlpha = crossFadeTime / crossFadeDuration;
        if (fadeAlpha < 1f) {
            music1.setVolume(1f - fadeAlpha);
            music2.setVolume(fadeAlpha);
        } else {
            music1.stop();
            music1.dispose();
            music1 = music2;
            music2 = null;
            music1.setVolume(1);
            currentTrack = nextTrack;
            nextTrack = null;
        }
    }
}

From source file:com.cyphercove.doublehelix.Particle.java

License:Apache License

private void updateCommon(float delta, boolean haveTouchVelocity, Vector3 touchPosition, Vector3 touchVelocity,
        float cameraDistance) {
    age += delta;/*from   w w  w . j a  va2 s.co m*/
    if (age < LIFE_FADE_TIME)
        ageFade = Interpolation.fade.apply(age / LIFE_FADE_TIME);
    else if (age > LIFE_FADE_OUT_TIME)
        ageFade = Interpolation.fade.apply((LIFE_TIME - age) / LIFE_FADE_TIME);
    else
        ageFade = 1;

    TMPV.set(center.x, center.y, 0);
    float distFromAccelerationCenter = TMPV.len() - RADIAL_ACCELERATION_MAX_CENTER;
    float radialAcceleration = RADIAL_ACCELERATION_MAX * (1F - Math.min(1f, Interpolation.fade
            .apply(Math.abs(distFromAccelerationCenter) / RADIAL_ACCELERATION_EFFECT_EXTENT)));
    TMPV.nor().rotate(Vector3.Z, 90f - (distFromAccelerationCenter * DEGREES_ACCLERATION_PER_DIST)); //motion direction
    TMPV.scl(radialAcceleration); //acceleration
    baseVelocity.add(TMPV.scl(delta)); //apply acceleration

    float dampenAmount = DAMPENING * baseVelocity.len() * delta;
    if (dampenAmount >= 1f)
        baseVelocity.set(0, 0, 0);
    else
        baseVelocity.add(TMPV.set(baseVelocity).scl(-dampenAmount));

    velocity.set(baseVelocity);

    if (haveTouchVelocity && cameraDistance <= TOUCH_CHECK_DISTANCE) {
        float dst = TMPV.set(center).sub(touchPosition).len();
        if (dst < TOUCH_INFLUENCE) {
            float mag = 1f - Math.min(1f, dst / TOUCH_INFLUENCE);
            if (mag > touchMagnitude) {
                touchMagnitude = mag;
                //float radialDst = distanceToAxis(center, touchPosition, touchVelocity);
                touchAge = 0;

                touchRotationVelocity.set(touchVelocity).scl(TOUCH_SPEED_RATIO * mag);
                touchRotationAxis.set(TMPV).crs(touchVelocity).nor();
            }
        }
    }

    if (touchMagnitude > 0) {
        touchAge += delta;

        if (touchAge > TOUCH_DAMPEN_TIME) {
            touchMagnitude = 0;
            TMPV.set(touchRotationVelocity).scl(0.5f);
            TMPV.rotate(touchRotationAxis, -45);
            baseVelocity.add(TMPV);
            velocity.set(baseVelocity);
        } else {
            float lerp = touchAge / TOUCH_DAMPEN_TIME;
            TMPV.set(touchRotationVelocity).scl(1f - 0.5f * Interpolation.pow2Out.apply(lerp));
            TMPV.rotate(touchRotationAxis, -Interpolation.pow3In.apply(lerp) * 45);
            velocity.add(TMPV);
        }
    }

    if (age >= LIFE_TIME) {
        center.set(originalCenter);
        age = 0;
    } else {
        center.add(TMPV.set(velocity).scl(delta));
    }
}

From source file:com.idp.engine.ui.graphics.actors.IdpTextField.java

private void onFocus() {
    underline.addAction(Actions.sizeTo(textField.getWidth() + getUnderlineLeft() + getUnderlineRight(),
            underline.getHeight(), 0.4f, Interpolation.pow2Out));
}

From source file:com.idp.engine.ui.graphics.actors.IdpTextField.java

private void onBlur() {
    underline.addAction(Actions.sizeTo(0, underline.getHeight(), 0.4f, Interpolation.pow2Out));
}

From source file:com.idp.engine.ui.graphics.actors.listview.ScrollBar.java

/**
 * Shows scroll bar.//  w w w .java2s . c  om
 * Alpha goes from 0 to normalAlpha.
 */
public void fadeIn() {
    if (state == FadeState.IN)
        return;
    state = FadeState.IN;
    clearActions();
    addAction(Actions.sequence(Actions.alpha(normalAlpha, fadeDuration, Interpolation.pow2Out),
            setFadeState(FadeState.NULL)));
}

From source file:com.idp.engine.ui.graphics.actors.listview.ScrollBar.java

/**
 * Hides scroll bar.//w w  w. j a  v  a2 s. com
 * Alpha goes from normalAlpha to 0.
 */
public void fadeOut() {
    if (state == FadeState.OUT)
        return;
    if (state != FadeState.IN)
        clearActions();
    state = FadeState.OUT;
    addAction(Actions.sequence(Actions.delay(fadeDelay), Actions.alpha(0, fadeDuration, Interpolation.pow2Out),
            setFadeState(FadeState.NULL)));
}

From source file:com.idp.engine.ui.graphics.actors.listview.ScrollBar.java

/**
 * Creates (but not adds it to the scrollbar) action that will fade out scrollbar after {@code fadeDelay} seconds.
 * @return newly created delayed fadeout action
 *//*from www .jav  a  2 s  .  com*/
Action delayedFadeOut() {
    return Actions.addAction(Actions.sequence(Actions.delay(fadeDelay), setFadeState(FadeState.OUT),
            Actions.alpha(0, fadeDuration, Interpolation.pow2Out), setFadeState(FadeState.NULL)), this);
}

From source file:com.jmolina.orb.elements.Orb.java

License:Open Source License

/**
 * Ejecuta la animacion de salida/* w  w  w  .jav a2  s . c  o m*/
 *
 * @param toSuccess Callback de cambio a la pantalla de exito
 */
public void applyOutroAction(Runnable toSuccess) {
    getActor()
            .addAction(sequence(
                    parallel(rotateBy(1080, OUTRO_TIME, Interpolation.pow2Out),
                            scaleTo(4 * this.getNaturalScale(), 4 * this.getNaturalScale(), OUTRO_TIME,
                                    Interpolation.pow2),
                            fadeOut(OUTRO_TIME, Interpolation.pow2)),
                    run(toSuccess)));
}