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

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

Introduction

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

Prototype

PowIn pow2In

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

Click Source Link

Usage

From source file:com.esotericsoftware.spine.superspineboy.Model.java

License:Open Source License

float getTimeScale() {
    if (player.hp == 0)
        return timeScale
                * Interpolation.pow2In.apply(0, 1, MathUtils.clamp(gameOverTimer / gameOverSlowdown, 0.01f, 1));
    return timeScale;
}

From source file:com.esotericsoftware.spine.superspineboy.PlayerView.java

License:Open Source License

void update(float delta) {
    // When not shooting, reset the number of burst shots.
    if (!view.touched && burstTimer > 0) {
        burstTimer -= delta;//from ww w .  j  a  v  a  2  s  .co  m
        if (burstTimer < 0)
            burstShots = 0;
    }

    // If jump was pressed in the air, jump as soon as grounded.
    if (view.jumpPressed && player.isGrounded())
        jump();

    skeleton.setX(player.position.x + width / 2);
    skeleton.setY(player.position.y);

    if (!setAnimation(view.assets.playerStates.get(player.state), player.stateChanged))
        animationState.update(delta);
    animationState.apply(skeleton);

    Vector2 mouse = temp1.set(Gdx.input.getX(), Gdx.input.getY());
    view.viewport.unproject(mouse);

    // Determine if the player can shoot at the mouse position.
    canShoot = false;
    if (rearUpperArmBone == null || rearBracerBone == null || gunBone == null)
        canShoot = true;
    else if (player.hp > 0 && !view.ui.hasSplash
            && (Math.abs(skeleton.getY() - mouse.y) > 2.7f || Math.abs(skeleton.getX() - mouse.x) > 0.75f)) {
        // Store bone rotations from the animation that was applied.
        float rearUpperArmRotation = rearUpperArmBone.getRotation();
        float rearBracerRotation = rearBracerBone.getRotation();
        float gunRotation = gunBone.getRotation();
        // Straighten the arm and don't flipX, so the arm can more easily point at the mouse.
        rearUpperArmBone.setRotation(0);
        float shootRotation = 11;
        if (animationState.getCurrent(1) == null) {
            rearBracerBone.setRotation(0);
            gunBone.setRotation(0);
        } else
            shootRotation += 25; // Use different rotation when shoot animation was applied.
        skeleton.setFlipX(false);
        skeleton.updateWorldTransform();

        // Compute the arm's angle to the mouse, flipping it based on the direction the player faces.
        Vector2 bonePosition = temp2.set(rearUpperArmBone.getWorldX() + skeleton.getX(),
                rearUpperArmBone.getWorldY() + skeleton.getY());
        float angle = bonePosition.sub(mouse).angle();
        float behind = (angle < 90 || angle > 270) ? -1 : 1;
        if (behind == -1)
            angle = -angle;
        if (player.state == State.idle
                || (view.touched && (player.state == State.jump || player.state == State.fall)))
            player.dir = behind;
        if (behind != player.dir)
            angle = -angle;
        if (player.state != State.idle && behind != player.dir) {
            // Don't allow the player to shoot behind themselves unless idle. Use the rotations stored earlier from the animation.
            rearBracerBone.setRotation(rearBracerRotation);
            rearUpperArmBone.setRotation(rearUpperArmRotation);
            gunBone.setRotation(gunRotation);
        } else {
            if (behind == 1)
                angle += 180;
            // Adjust the angle upward based on the number of shots in the current burst.
            angle += kickbackAngle * Math.min(1, burstShots / kickbackShots) * (burstTimer / burstDuration);
            float gunArmAngle = angle - shootRotation;
            // Compute the head, torso and front arm angles so the player looks up or down.
            float headAngle;
            if (player.dir == -1) {
                angle += 360;
                if (angle < 180)
                    headAngle = 25 * Interpolation.pow2In.apply(Math.min(1, angle / 50f));
                else
                    headAngle = -15 * Interpolation.pow2In.apply(1 - Math.max(0, angle - 310) / 50f);
            } else {
                if (angle < 360)
                    headAngle = -15 * Interpolation.pow2In.apply(1 - Math.max(0, (angle - 310) / 50f));
                else
                    headAngle = 25 * Interpolation.pow2In.apply(1 - Math.max(0, (410 - angle) / 50f));
            }
            float torsoAngle = headAngle * 0.75f;
            if (headBone != null)
                headBone.setRotation(headBone.getRotation() + headAngle);
            if (torsoBone != null)
                torsoBone.setRotation(torsoBone.getRotation() + torsoAngle);
            if (frontUpperArmBone != null)
                frontUpperArmBone.setRotation(frontUpperArmBone.getRotation() - headAngle * 1.4f);
            rearUpperArmBone.setRotation(gunArmAngle - torsoAngle - rearUpperArmBone.getWorldRotation());
            canShoot = true;
        }
    }

    skeleton.setFlipX(player.dir == -1);
    skeleton.updateWorldTransform();
}

From source file:com.jmolina.orb.widgets.game.Fragments.java

License:Open Source License

/**
 * Ejecuta la animacion de destruccion del orbe.
 *///from   ww w . j  a  v  a 2s .c om
public void destroy() {
    explosion.addAction(sequence(alpha(0.4f),
            parallel(scaleTo(3, 3, 0.3f, Interpolation.exp5Out), fadeOut(0.3f, Interpolation.exp5Out))));
    fragment1.addAction(getDestructionAction());
    fragment2.addAction(getDestructionAction());
    fragment3.addAction(getDestructionAction());
    fragment4.addAction(getDestructionAction());

    addAction(sequence(delay(0.25f * ANIMATION_TIME), fadeOut(0.5f * ANIMATION_TIME, Interpolation.pow2In)));
}

From source file:com.jmolina.orb.widgets.game.LinearField.java

License:Open Source License

@Override
protected Action getAttraction() {
    RepeatAction forever = new RepeatAction();
    forever.setCount(RepeatAction.FOREVER);
    forever.setAction(new SequenceAction(
            parallel(moveTo(0, Utils.cell(2 * getThreshold()) - particle.getHeight(), 0), alpha(0),
                    scaleTo(particle.getScaleX(), 1)),
            parallel(moveTo(0, Utils.cell(getThreshold()), PERIOD, Interpolation.pow2In),
                    alpha(MAX_ALPHA, PERIOD, Interpolation.pow2In)),
            parallel(scaleTo(particle.getScaleX(), 0, SHORT_TIME))));

    return forever;
}

From source file:com.jmolina.orb.widgets.game.RadialField.java

License:Open Source License

@Override
protected Action getAttraction() {
    RepeatAction forever = new RepeatAction();
    forever.setCount(RepeatAction.FOREVER);
    forever.setAction(new SequenceAction(parallel(scaleTo(1, 1), alpha(0)), parallel(
            scaleTo(0, 0, PERIOD, Interpolation.pow2In), alpha(MAX_ALPHA, PERIOD, Interpolation.pow2In))));

    return forever;
}

From source file:es.eucm.ead.editor.view.listeners.VisibleListener.java

License:Open Source License

public void setVisible(boolean visible) {
    if (actor.getActions().size > 0 || visible != actor.isVisible()) {
        actor.clearActions();//from www .  j a va2  s .  com
        if (visible) {
            actor.addAction(
                    Actions.sequence(Actions.visible(true), Actions.rotateTo(0, 0), Actions.scaleTo(0.5f, 0.5f),
                            Actions.parallel(Actions.fadeIn(ANIM_TIME), Actions.scaleTo(1, 1, ANIM_TIME),
                                    Actions.rotateBy(360, ANIM_TIME, Interpolation.pow2Out))));
        } else {
            actor.addAction(
                    Actions.sequence(Actions.rotateTo(0, 0),
                            Actions.parallel(Actions.fadeOut(ANIM_TIME), Actions.scaleTo(0.5f, 0.5f, ANIM_TIME),
                                    Actions.rotateBy(-360, ANIM_TIME, Interpolation.pow2In)),
                            Actions.visible(false)));
        }
    }
}

From source file:es.eucm.ead.engine.systems.effects.transitions.Slide.java

License:Open Source License

private void initialize(float duration, int direction, boolean slideOut, boolean over) {
    this.duration = duration;
    this.direction = direction == RANDOM ? MathUtils.random(LEFT, DOWN) : direction;
    this.slideOut = slideOut;
    this.easing = slideOut ? Interpolation.pow2Out : Interpolation.pow2In;
    this.over = over;
}