few UX improvements
This commit is contained in:
@@ -6,44 +6,31 @@ extends Camera2D
|
||||
var should_move_right = false
|
||||
var should_move_left = false
|
||||
|
||||
@onready var arrow_001: Sprite2D = $"../Arrow001"
|
||||
@onready var arrow_002: Sprite2D = $"../Arrow002"
|
||||
signal move_to_reception_finished
|
||||
signal move_to_dining_room_finished
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
arrow_001.visible = position.x <= 440.0
|
||||
arrow_002.visible = position.x >= 2076.0
|
||||
func move_to_reception() -> void:
|
||||
var camera_tween = get_tree().create_tween()
|
||||
camera_tween.set_ease(Tween.EASE_IN_OUT)
|
||||
camera_tween.set_trans(Tween.TRANS_CUBIC)
|
||||
camera_tween.tween_property(self, "position", Vector2.ZERO, 0.5)
|
||||
camera_tween.tween_callback(on_move_to_reception_finished)
|
||||
|
||||
var limit_left_at_center = limit_left + get_viewport_rect().size.x/2
|
||||
var limit_right_at_center = limit_right - get_viewport_rect().size.x/2
|
||||
if position.x < limit_left_at_center:
|
||||
position.x = limit_left_at_center
|
||||
if position.x > limit_right_at_center:
|
||||
position.x = limit_right_at_center
|
||||
|
||||
if should_move_right and position.x < limit_right_at_center:
|
||||
position.x += pan_speed
|
||||
if should_move_left and position.x > limit_left_at_center:
|
||||
position.x -= pan_speed
|
||||
func on_move_to_reception_finished() -> void:
|
||||
move_to_reception_finished.emit()
|
||||
|
||||
func move_to_dining_room() -> void:
|
||||
var camera_tween = get_tree().create_tween()
|
||||
camera_tween.set_ease(Tween.EASE_IN_OUT)
|
||||
camera_tween.set_trans(Tween.TRANS_CUBIC)
|
||||
camera_tween.tween_property(self, "position", Vector2(2720.0, 0), 0.5)
|
||||
camera_tween.tween_callback(on_move_to_dining_room_finished)
|
||||
|
||||
func on_move_to_dining_room_finished() -> void:
|
||||
move_to_dining_room_finished.emit()
|
||||
|
||||
func _on_pan_right_mouse_entered() -> void:
|
||||
should_move_right = true
|
||||
func _on_arrow_right_on_clicked() -> void:
|
||||
move_to_dining_room()
|
||||
|
||||
|
||||
func _on_pan_right_mouse_exited() -> void:
|
||||
should_move_right = false
|
||||
|
||||
|
||||
func _on_pan_left_mouse_entered() -> void:
|
||||
should_move_left = true
|
||||
|
||||
|
||||
func _on_pan_left_mouse_exited() -> void:
|
||||
should_move_left = false
|
||||
func _on_arrow_left_on_clicked() -> void:
|
||||
move_to_reception()
|
||||
|
||||
Reference in New Issue
Block a user