use of com.bladecoder.engine.model.SceneCamera in project bladecoder-adventure-engine by bladecoder.
the class CameraAction method run.
@Override
public boolean run(VerbRunner cb) {
Vector2 pos2 = null;
Float zoom2 = zoom;
if (pos != null)
pos2 = new Vector2(pos);
float scale = EngineAssetManager.getInstance().getScale();
SceneCamera camera = World.getInstance().getSceneCamera();
if (zoom2 == null || zoom2 < 0)
zoom2 = camera.getZoom();
if (pos == null && target == null) {
pos2 = new Vector2(camera.getPosition());
pos2.x /= scale;
pos2.y /= scale;
}
if (target != null) {
BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
float x = target.getX();
float y = target.getY();
if (target instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) target).getRefPoint();
x += refPoint.x;
y += refPoint.y;
}
if (pos2 != null) {
pos2.x += x;
pos2.y += y;
} else {
pos2 = new Vector2(x, y);
}
}
if (followActor != null) {
if (followActor.equals("none"))
World.getInstance().getCurrentScene().setCameraFollowActor(null);
else {
World.getInstance().getCurrentScene().setCameraFollowActor((SpriteActor) World.getInstance().getCurrentScene().getActor(followActor, false));
}
}
if (duration == null || duration == 0) {
camera.setZoom(zoom2);
camera.setPosition(pos2.x * scale, pos2.y * scale);
return false;
} else {
camera.startAnimation(pos2.x * scale, pos2.y * scale, zoom2, duration, interpolation, wait ? cb : null);
}
return wait;
}
Aggregations