hero-mark-2/cutscenes/fami_cutscene.gd

45 lines
1.3 KiB
GDScript

extends Node2D
signal cutscene_finished
const DeathParticles = preload("res://objects/enemy/death_particles.tscn")
export var cutscene_skip: float = 92.0
onready var animation_player: AnimationPlayer = $AnimationPlayer
func _init() -> void:
connect("cutscene_finished", self, "_on_cutscene_finished")
func _on_cutscene_finished() -> void:
Game.can_pause = true
func _physics_process(delta: float) -> void:
if animation_player.current_animation_position < cutscene_skip:
Game.can_pause = false
func _input(event: InputEvent) -> void:
if event.is_action_pressed("jump") and animation_player.current_animation_position < (cutscene_skip - Options.transition_speed_secs * 2.0):
skip_cutscene()
func skip_cutscene() -> void:
Fade.fade_out(Options.transition_speed_secs)
yield(Fade, "fade_finished")
animation_player.seek(cutscene_skip)
Fade.fade_in(Options.transition_speed_secs)
func kill_cop() -> void:
var splatter := DeathParticles.instance()
splatter.global_position = $Cop.global_position
splatter.emitting = true
add_child(splatter)
$Cop.queue_free()
func _notification(what: int) -> void:
match what:
NOTIFICATION_WM_FOCUS_OUT:
animation_player.playback_active = false
$FamiVoice.stream_paused = true
NOTIFICATION_WM_FOCUS_IN:
animation_player.playback_active = true
$FamiVoice.stream_paused = false