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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations