use of com.bladecoder.engine.anim.SpritePosTween in project bladecoder-adventure-engine by bladecoder.
the class PositionAnimAction method run.
@Override
public boolean run(VerbRunner cb) {
float scale = EngineAssetManager.getInstance().getScale();
BaseActor a = World.getInstance().getCurrentScene().getActor(actor, true);
float x = a.getX();
float y = a.getY();
if (target != null) {
BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
x = target.getX();
y = target.getY();
if (target instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) target).getRefPoint();
x += refPoint.x;
y += refPoint.y;
}
if (pos != null) {
x += pos.x * scale;
y += pos.y * scale;
}
} else if (pos != null) {
x = pos.x * scale;
y = pos.y * scale;
}
if (speed == 0 || !(a instanceof SpriteActor)) {
a.setPosition(x, y);
return false;
} else {
// WARNING: only spriteactors support animation
float s;
if (mode != null && mode == Mode.SPEED) {
Vector2 p0 = new Vector2(a.getX(), a.getY());
s = p0.dst(x, y) / (scale * speed);
} else {
s = speed;
}
SpritePosTween t = new SpritePosTween();
t.start((SpriteActor) a, repeat, count, x, y, s, interpolation, wait ? cb : null);
((SpriteActor) a).addTween(t);
}
return wait;
}
Aggregations