I am trying to animate, from not follow a Component, to follow a Component - and then lastly animate back again to not following the component.
// this.camera.follow = Tween()
this.camera.followBodyComponent(SomeComponent);
Do you know how?
I tried something like this:
bool tappedComponent = false;
Vector2 cameraGoToPosition = Vector2(0,0);
Vector2 cameraFromPosition = Vector2(0,0);
void zoomTo(BodyComponent body, Vector2 vec){
cameraFromPosition = body.center;
camera.follow = cameraGoToPosition;
}
@override
void update(double dt) {
super.update(dt);
cameraGoToPosition = cameraGoToPosition * dt;
camera.position = cameraGoToPosition;
}
But camera.position
has no setter or getter?
Update: found that:
camera.moveTo(body.center);
// camera.moveTo(worldToScreen(body.center));
Is moving in an animated way, but it do not put the Component in the center of the screen?