mirror of
https://github.com/kodzukye/omens-ascent.git
synced 2026-08-10 05:13:10 +00:00
48 lines
1.3 KiB
GDScript
48 lines
1.3 KiB
GDScript
class_name Credits
|
|
extends Control
|
|
|
|
signal credits_finished
|
|
|
|
const SCROLL_SPEED: float = 40.0
|
|
const FADE_IN_DURATION: float = 1.2
|
|
const ENTRY_ROW_SCENE: PackedScene = preload("res://scenes/components/credit_entry_row.tscn")
|
|
|
|
@export var entries: Array[CreditEntry] = []
|
|
|
|
@onready var _scroll_container: Control = $Control
|
|
@onready var _entry_container: VBoxContainer = $Control/VBoxContainer
|
|
@onready var _fade_in: ColorRect = $FadeIn
|
|
|
|
var _scrolling: bool = false
|
|
|
|
func _ready() -> void:
|
|
_build_entries()
|
|
await get_tree().process_frame
|
|
_entry_container.position.y = _scroll_container.size.y
|
|
|
|
var tween: Tween = create_tween()
|
|
tween.tween_property(_fade_in, "color:a", 0.0, FADE_IN_DURATION)
|
|
await tween.finished
|
|
|
|
_scrolling = true
|
|
|
|
func _process(delta: float) -> void:
|
|
if not _scrolling:
|
|
return
|
|
|
|
_entry_container.position.y -= SCROLL_SPEED * delta
|
|
|
|
if _entry_container.position.y <= -_entry_container.size.y:
|
|
_scrolling = false
|
|
_on_credits_finished()
|
|
|
|
func _build_entries() -> void:
|
|
for entry: CreditEntry in entries:
|
|
var row: CreditEntryRow = ENTRY_ROW_SCENE.instantiate()
|
|
_entry_container.add_child(row)
|
|
row.setup(entry)
|
|
|
|
func _on_credits_finished() -> void:
|
|
credits_finished.emit()
|
|
SceneManager.change_scene("res://scenes/components/title_screen.tscn")
|