Search in sources :

Example 1 with MoveByAction

use of com.badlogic.gdx.scenes.scene2d.actions.MoveByAction in project Eidolons by IDemiurge.

the class AnimMultiplicator method createAndAddEmitterActions.

private void createAndAddEmitterActions(EmitterActor actor, Coordinates c) {
    // MoveToAction action = ActorMaster.getMoveToAction(c, actor, pixelsPerSecond);
    Vector2 v = getCenteredPos(c);
    float speed = getPixelsPerSecond();
    if (template != null) {
        GridMaster.offset(getOrigin(), v, template.getAdditionalDistance(getActive()));
        speed = template.speed;
    }
    MoveByAction action = ActorMaster.getMoveByAction(getOrigin(), v, actor, (int) speed);
    if (action.getDuration() > this.duration) {
        this.duration = action.getDuration();
    }
    // ActorMaster.addRemoveAfter(actor);
    actor.getEffect().setDuration((int) action.getDuration());
    anim.setDuration(duration);
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)

Example 2 with MoveByAction

use of com.badlogic.gdx.scenes.scene2d.actions.MoveByAction in project Eidolons by IDemiurge.

the class AttackAnim method getMoveAction.

protected MoveByAction getMoveAction(float x, float y, float duration) {
    MoveByAction mainMove = new MoveByAction();
    mainMove.setDuration(duration);
    int distanceX = getOriginCoordinates().getX() - // getActive().getAnimator().getAnimRef().getTargetObj()
    getDestinationCoordinates().getX();
    x -= distanceX * GridMaster.CELL_W;
    int distanceY = getOriginCoordinates().getY() - // getActive().getAnimator().getAnimRef().getTargetObj()
    getDestinationCoordinates().getY();
    y += distanceY * GridMaster.CELL_H;
    mainMove.setAmount(x, y);
    return mainMove;
}
Also used : MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)

Example 3 with MoveByAction

use of com.badlogic.gdx.scenes.scene2d.actions.MoveByAction in project Eidolons by IDemiurge.

the class AnimMultiplicator method addRangeAndAngle.

private Action addRangeAndAngle(int angle, int range, EmitterActor actor) {
    MoveByAction action = new MoveByAction();
    float x = (float) (132 * Math.sin(angle) * range);
    float y = (float) (132 * Math.cos(angle) * range);
    action.setAmount(x, y);
    actor.setRotation(-angle);
    actor.addAction(action);
    action.setTarget(actor);
    Float duration = (float) (Math.sqrt(x * x + y * y) / getPixelsPerSecond());
    action.setDuration(duration);
    if (duration > this.duration) {
        this.duration = duration;
    }
    ActorMaster.addRemoveAfter(actor);
    // TRY ALPHA/ROTATE ACTION
    return action;
}
Also used : MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)

Example 4 with MoveByAction

use of com.badlogic.gdx.scenes.scene2d.actions.MoveByAction in project Eidolons by IDemiurge.

the class ReloadAnim method getMoveAmmoAction.

protected MoveByAction getMoveAmmoAction() {
    MoveByAction mainMove = new MoveByAction();
    mainMove.setAmount(destination.x - origin.x, destination.y - origin.y);
    mainMove.setDuration(duration);
    return mainMove;
}
Also used : MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)

Example 5 with MoveByAction

use of com.badlogic.gdx.scenes.scene2d.actions.MoveByAction in project Eidolons by IDemiurge.

the class AttackAnim method getAction.

/*
delayAction
scale
size - elongate
 */
// TODO back?
@Override
protected Action getAction() {
    // if (sequence != null)  //reset sometimes?
    // return sequence;
    sequence = new SequenceAction();
    int i = 0;
    float totalDuration = 0;
    for (ATK_ANIMS anim : anims) {
        for (float angle : anim.targetAngles) {
            List<Pair<MoveByAction, RotateByAction>> swings = new ArrayList<>();
            float duration = this.duration;
            if (duration <= 0) {
                duration = 1;
            }
            // anim.durations[i];
            totalDuration += duration;
            float x = anim.offsetsX[i];
            float y = anim.offsetsY[i];
            MoveByAction mainMove = null;
            try {
                mainMove = getMoveAction(x, y, duration);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
            if (mainMove == null) {
                return null;
            }
            RotateByAction mainRotate = getRotateAction(angle, duration);
            swings.add(new ImmutablePair<>(mainMove, mainRotate));
            swings.forEach(swing -> {
                sequence.addAction(new ParallelAction(swing.getKey(), swing.getValue()));
            });
            i++;
        }
    }
    setDuration(totalDuration);
    return sequence;
}
Also used : ParallelAction(com.badlogic.gdx.scenes.scene2d.actions.ParallelAction) RotateByAction(com.badlogic.gdx.scenes.scene2d.actions.RotateByAction) ArrayList(java.util.ArrayList) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Aggregations

MoveByAction (com.badlogic.gdx.scenes.scene2d.actions.MoveByAction)5 Vector2 (com.badlogic.gdx.math.Vector2)1 ParallelAction (com.badlogic.gdx.scenes.scene2d.actions.ParallelAction)1 RotateByAction (com.badlogic.gdx.scenes.scene2d.actions.RotateByAction)1 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)1 ArrayList (java.util.ArrayList)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1