Ver Fonte

:wrench: Add easing and transition type

DricomDragon há 2 anos atrás
pai
commit
b7d2765e23
2 ficheiros alterados com 15 adições e 11 exclusões
  1. 13 11
      godot/projector/focus/Focus.gd
  2. 2 0
      godot/run/root.tscn

+ 13 - 11
godot/projector/focus/Focus.gd

@@ -8,15 +8,16 @@ 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_group("Move", "move_")
 @export var move_duration: float = 1.0
+@export var move_trans: Tween.TransitionType = Tween.TRANS_SINE
+@export var move_ease: Tween.EaseType = Tween.EASE_IN_OUT
 
-@export_group("Step inward", "in_")
-@export var in_duration: float = 1.0
+@export_group("Zoom", "zoom_")
+@export var zoom_duration: float = 1.0
+@export var zoom_trans: Tween.TransitionType = Tween.TRANS_SINE
+@export var zoom_closer_ease: Tween.EaseType = Tween.EASE_IN
+@export var zoom_wider_ease: Tween.EaseType = Tween.EASE_OUT
 
 var tween: Tween
 
@@ -26,12 +27,13 @@ func focus_on(pos: Vector2, scope: float) -> void:
 		tween.kill()
 
 	var target_zoom = Vector2.ONE / scope
-	var min_zoom = target_zoom if target_zoom.x < get_zoom().x else get_zoom()
+	var is_wider = target_zoom.x < get_zoom().x
+	var min_zoom = target_zoom if is_wider else get_zoom()
+	var zoom_ease = zoom_wider_ease if is_wider else zoom_closer_ease
 
 	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_property(self, "position", pos, move_duration).set_trans(move_trans).set_ease(move_ease)
+	tween.tween_property(self, "zoom", target_zoom, zoom_duration).set_trans(zoom_trans).set_ease(zoom_ease)
 	tween.tween_callback(end)
 
 

+ 2 - 0
godot/run/root.tscn

@@ -92,6 +92,8 @@ position = Vector2(2, 0)
 position = Vector2(8904, 4626)
 anchor_mode = 1
 zoom = Vector2(0.1, 0.1)
+tween_is_parallel = true
+zoom_trans = 10
 
 [node name="Show" parent="Board" instance=ExtResource("2_cih7e")]
 start_slide = 50