stick-the-quick/startup/TitleScreen.gd

45 lines
1.1 KiB
GDScript

class_name TitleScreen extends Node
@export var next: PackedScene
@onready var anim_player := $AnimationPlayer as AnimationPlayer
@onready var grabber := (
$'Node3D/CameraGrabber' as CameraGrabber
)
var skipping := false
var closing := false
var starting := true
func anim_done() -> bool:
return (
anim_player.current_animation == &'skip' or
anim_player.current_animation_position >= 14.3
)
func _unhandled_input(event: InputEvent) -> void:
if (
event.is_action_released(&'confirm') or
event.is_action_released(&'cancel') or
event.is_action_released(&'interact') or
event.is_action_released(&'pause') or
event.is_action_released(&'alt_pause')
) and (not starting) and not closing:
if anim_done():
closing = true
await FX.fade(Color.BLACK)
$Node3D/CameraGrabber.relinquish()
FX.get_camera().transform = Transform3D.IDENTITY
Storyboard.go_to_non_level_scene(next)
elif not skipping:
skipping = true
await FX.fade(Color.WHITE)
anim_player.play(&'skip', 0.0)
await FX.clear_fade()
func _ready() -> void:
await FX.fade(Color.BLACK, 0.0)
await FX.clear_fade(1.0)
anim_player.play(&'title_screen_events')
starting = false