44 lines
1.0 KiB
GDScript
44 lines
1.0 KiB
GDScript
extends Control
|
|
@onready var Handle : Control = $Handle
|
|
|
|
@export var scroll_speed: float = 50.0
|
|
|
|
var original : Vector2
|
|
var offset : Vector2
|
|
var playing : bool
|
|
|
|
func _ready() -> void:
|
|
print("credits_roll.gd: _ready()")
|
|
original = Handle.position
|
|
set_process_input(false)
|
|
|
|
func _process(delta: float) -> void:
|
|
if playing:
|
|
offset.y -= scroll_speed * delta
|
|
Handle.position = offset
|
|
|
|
func _gui_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("ui_menu") or event.is_action_pressed("ui_cancel") or event.is_action_pressed("ui_accept"):
|
|
stop()
|
|
|
|
func play() -> void:
|
|
print("credits_roll.gd: show()")
|
|
set_process_input(true)
|
|
offset = original
|
|
Handle.position = original
|
|
playing = true
|
|
modulate.a = 0
|
|
visible = true
|
|
var tween := create_tween()
|
|
tween.tween_property(self, "modulate:a", 1.0, 5.0)
|
|
await tween.finished
|
|
|
|
func stop() -> void:
|
|
print("credits_roll.gd: hide()")
|
|
set_process_input(false)
|
|
var tween := create_tween()
|
|
tween.tween_property(self, "modulate:a", 0.0, 2.0)
|
|
await tween.finished
|
|
playing = false
|
|
visible = false
|
|
|