103 lines
3.3 KiB
Plaintext
103 lines
3.3 KiB
Plaintext
[gd_scene load_steps=2 format=3 uid="uid://bi2c4ph8txa4y"]
|
|
|
|
[sub_resource type="GDScript" id="GDScript_e7tbc"]
|
|
script/source = "extends Node2D
|
|
|
|
# Example cutscene using the cutscene editor plugin
|
|
|
|
# Character nodes
|
|
@onready var character1: Node2D = $Character1
|
|
@onready var character2: Node2D = $Character2
|
|
|
|
# Cutscene manager
|
|
var cutscene_manager: CutsceneManager
|
|
|
|
func _ready() -> void:
|
|
# Initialize the cutscene system
|
|
setup_cutscene()
|
|
|
|
# Start the cutscene after a short delay to see the initial positions
|
|
var start_timer = Timer.new()
|
|
start_timer.wait_time = 1.0
|
|
start_timer.one_shot = true
|
|
start_timer.connect(\"timeout\", start_cutscene)
|
|
add_child(start_timer)
|
|
start_timer.start()
|
|
|
|
func setup_cutscene() -> void:
|
|
# Create the cutscene manager
|
|
cutscene_manager = CutsceneManager.new()
|
|
add_child(cutscene_manager)
|
|
|
|
# Connect to cutscene signals
|
|
cutscene_manager.connect(\"cutscene_started\", _on_cutscene_started)
|
|
cutscene_manager.connect(\"cutscene_completed\", _on_cutscene_completed)
|
|
cutscene_manager.connect(\"action_started\", _on_action_started)
|
|
cutscene_manager.connect(\"action_completed\", _on_action_completed)
|
|
|
|
# Create the action sequence as described in requirements
|
|
|
|
# 1. & 2. Characters move simultaneously
|
|
var parallel_moves = [
|
|
MoveAction.new(character1, Vector2(234, 591), 100.0), # Character1 moves
|
|
MoveAction.new(character2, Vector2(912, 235), 100.0) # Character2 moves
|
|
]
|
|
cutscene_manager.add_parallel_actions(parallel_moves)
|
|
|
|
# 3. Character2 turns to face Character1
|
|
var turn_action = TurnAction.new(character2, character1, 1.0)
|
|
cutscene_manager.add_action(turn_action)
|
|
|
|
# 4. Character2 says dialogue
|
|
var dialogue_action = DialogueAction.new(character2, \"Hello there, friend!\", 2.0)
|
|
cutscene_manager.add_action(dialogue_action)
|
|
|
|
# 5. Character1 plays shocked animation (simulated with a wait since we don't have an actual animation)
|
|
var animation_action = WaitAction.new(1.0) # Simulate animation with wait
|
|
cutscene_manager.add_action(animation_action)
|
|
|
|
# Add a final dialogue from character1
|
|
var final_dialogue = DialogueAction.new(character1, \"That was surprising!\", 2.0)
|
|
cutscene_manager.add_action(final_dialogue)
|
|
|
|
func start_cutscene() -> void:
|
|
print(\"Starting cutscene...\")
|
|
cutscene_manager.start()
|
|
|
|
func _on_cutscene_started() -> void:
|
|
print(\"Cutscene started!\")
|
|
|
|
func _on_cutscene_completed() -> void:
|
|
print(\"Cutscene completed!\")
|
|
print(\"Final positions:\")
|
|
print(\"Character1: %s\" % character1.position)
|
|
print(\"Character2: %s\" % character2.position)
|
|
|
|
func _on_action_started(action: Action) -> void:
|
|
print(\"Action started: %s\" % action.name)
|
|
|
|
func _on_action_completed(action: Action) -> void:
|
|
print(\"Action completed: %s\" % action.name)
|
|
|
|
# Clean up when the node is removed
|
|
func _exit_tree() -> void:
|
|
if cutscene_manager:
|
|
cutscene_manager.queue_free()
|
|
"
|
|
|
|
[node name="ExampleCutscene" type="Node2D"]
|
|
script = SubResource("GDScript_e7tbc")
|
|
|
|
[node name="Character1" type="Node2D" parent="."]
|
|
position = Vector2(234, 591)
|
|
|
|
[node name="Polygon2D" type="Polygon2D" parent="Character1"]
|
|
polygon = PackedVector2Array(-5, -19, -27, 2, 2, 15, 15, 6, 9, -19)
|
|
|
|
[node name="Character2" type="Node2D" parent="."]
|
|
position = Vector2(912, 235)
|
|
rotation = 2.60138
|
|
|
|
[node name="Polygon2D2" type="Polygon2D" parent="Character2"]
|
|
polygon = PackedVector2Array(10, -25, -43, 1, -14, 40, 48, 13)
|