|
@@ -5,10 +5,37 @@ extends Camera2D
|
|
|
|
|
|
signal ended
|
|
|
|
|
|
+@export_group("Tween caracteristics", "tween_")
|
|
|
+@export var tween_is_parallel: bool = false
|
|
|
+
|
|
|
+@export_group("Step backward", "back_")
|
|
|
+@export var back_zoom_multiplier: float = 0.8
|
|
|
+@export var back_duration: float = 1.0
|
|
|
+
|
|
|
+@export_group("Move focus", "move_")
|
|
|
+@export var move_duration: float = 1.0
|
|
|
+
|
|
|
+@export_group("Step inward", "in_")
|
|
|
+@export var in_duration: float = 1.0
|
|
|
+
|
|
|
+var tween: Tween
|
|
|
+
|
|
|
|
|
|
func focus_on(pos: Vector2, scope: float) -> void:
|
|
|
- set_position(pos)
|
|
|
- set_zoom(Vector2.ONE / scope)
|
|
|
+ if tween:
|
|
|
+ tween.kill()
|
|
|
+
|
|
|
+ var target_zoom = Vector2.ONE / scope
|
|
|
+ var min_zoom = target_zoom if target_zoom.x < get_zoom().x else get_zoom()
|
|
|
+
|
|
|
+ tween = create_tween().set_parallel(tween_is_parallel)
|
|
|
+ tween.tween_property(self, "zoom", min_zoom * back_zoom_multiplier, back_duration)
|
|
|
+ tween.tween_property(self, "position", pos, move_duration)
|
|
|
+ tween.tween_property(self, "zoom", target_zoom, in_duration)
|
|
|
+ tween.tween_callback(end)
|
|
|
+
|
|
|
+
|
|
|
+func end():
|
|
|
ended.emit()
|
|
|
|
|
|
|