update and improve ui
This commit was merged in pull request #36.
This commit is contained in:
@@ -5,12 +5,13 @@ extends Control
|
||||
|
||||
var initial_pos_saved := false
|
||||
var initial_pos: Vector2
|
||||
var appear_tween: Tween
|
||||
var move_tween: Tween
|
||||
var is_photo_mode_enable = false
|
||||
var current_execution: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
CollectionManager.on_photo_saved.connect(_set_photo_taken)
|
||||
CollectionManager.on_photo_preview_ready.connect(_set_photo_preview)
|
||||
GameState.on_enable_photo_mode_request.connect(_on_enable_photo_mode)
|
||||
GameState.on_disable_photo_mode_request.connect(_on_disable_photo_mode)
|
||||
GameState.on_photo_taken_finished.connect(_show_photo_taken)
|
||||
@@ -19,8 +20,7 @@ func _ready() -> void:
|
||||
func _hide_photo_taken() -> void:
|
||||
hide()
|
||||
|
||||
func _set_photo_taken(file_path) -> void:
|
||||
var image = Image.load_from_file(file_path)
|
||||
func _set_photo_preview(image: Image) -> void:
|
||||
if image:
|
||||
var texture = ImageTexture.create_from_image(image)
|
||||
photo_texture.texture = texture
|
||||
@@ -41,12 +41,17 @@ func _show_photo_taken() -> void:
|
||||
rotation_degrees = 0.0
|
||||
show()
|
||||
|
||||
var explode_tween_duration = 5.5
|
||||
var appear_duration = 0.8
|
||||
var float_duration = 1.5
|
||||
var move_tween_duration = 1.0
|
||||
var shrink_duration = 1
|
||||
var scale_amt = 3.0
|
||||
|
||||
var explode_tween = TweenFX.explode(self, explode_tween_duration, 3)
|
||||
appear_tween = create_tween()
|
||||
appear_tween.tween_property(self, "scale", Vector2.ONE * scale_amt, appear_duration).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
|
||||
appear_tween.parallel().tween_property(self, "rotation_degrees", randf_range(-10, 10), appear_duration * 0.8)
|
||||
|
||||
await get_tree().create_timer(explode_tween_duration / 2).timeout
|
||||
await get_tree().create_timer(appear_duration + float_duration).timeout
|
||||
|
||||
if my_execution != current_execution:
|
||||
return
|
||||
@@ -61,10 +66,14 @@ func _show_photo_taken() -> void:
|
||||
|
||||
move_tween = create_tween()
|
||||
var target_pos = collectible_button.global_position
|
||||
|
||||
move_tween.tween_property(self, "global_position:x", target_pos.x, move_tween_duration).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
move_tween.parallel().tween_property(self, "global_position:y", target_pos.y, move_tween_duration).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN)
|
||||
|
||||
await explode_tween.finished
|
||||
move_tween.parallel().tween_property(self, "scale", Vector2.ONE * 0.1, shrink_duration).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN_OUT)
|
||||
move_tween.parallel().tween_property(self, "modulate:a", 0.0, shrink_duration).set_trans(Tween.TRANS_LINEAR)
|
||||
|
||||
await move_tween.finished
|
||||
|
||||
if my_execution != current_execution:
|
||||
return
|
||||
@@ -90,6 +99,8 @@ func _on_disable_photo_mode() -> void:
|
||||
|
||||
func reset() -> void:
|
||||
TweenFX.stop_all(self)
|
||||
if appear_tween:
|
||||
appear_tween.kill()
|
||||
if move_tween:
|
||||
move_tween.kill()
|
||||
hide()
|
||||
|
||||
Reference in New Issue
Block a user