Add sounds to intro scene

This commit is contained in:
Alice Gaudon 2020-08-18 11:05:27 +02:00
parent bcb80dbec9
commit 4636b3aefc
14 changed files with 115 additions and 13 deletions

View File

@ -8,16 +8,15 @@
{"timer": 2, "auto": true}, {"timer": 2, "auto": true},
{"name": "Crab", "expression": "eyes", "wait": true}, {"name": "Crab", "expression": "eyes", "wait": true, "audio": "herbert_eyes"},
{"name": "Ely"}, {"name": "Ely"},
{"name": "Crab", "expression": "first_step", "wait": true}, {"name": "Crab", "expression": "first_step", "wait": true, "audio": "herbert_first_step"},
{"name": "Ely"}, {"name": "Ely"},
{"name": "Crab", "expression": "second_step", "wait": true}, {"name": "Crab", "expression": "second_step", "wait": true, "audio": "herbert_second_step"},
{"name": "Ely"},
{"name": "Crab", "expression": "third_step", "wait": true},
{"name": "Ely"}, {"name": "Ely"},
{"name": "Crab", "expression": "third_step", "wait": true, "auto": true},
{"name": "Crab", "text": "Hey you!"}, {"name": "Crab", "text": "Hey you!", "audio": "herbert_is_happy"},
{"name": "Ely", "text": "... Huh?"}, {"name": "Ely", "text": "... Huh?"},
{"name": "Crab", "text": "You ok buddy?"}, {"name": "Crab", "text": "You ok buddy?"},
{"name": "Ely", "text": "I must be going crazy."}, {"name": "Ely", "text": "I must be going crazy."},

View File

@ -2,7 +2,6 @@
[ext_resource path="res://images/campfire/Ely_Sitting.png" type="Texture" id=1] [ext_resource path="res://images/campfire/Ely_Sitting.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1] [sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 ) atlas = ExtResource( 1 )
region = Rect2( 0, 0, 192, 108 ) region = Rect2( 0, 0, 192, 108 )
@ -551,6 +550,6 @@ region = Rect2( 1344, 1728, 192, 108 )
animations = [ { animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ), SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ), SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ), SubResource( 51 ), SubResource( 52 ), SubResource( 53 ), SubResource( 54 ), SubResource( 55 ), SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ), SubResource( 63 ), SubResource( 64 ), SubResource( 65 ), SubResource( 66 ), SubResource( 67 ), SubResource( 68 ), SubResource( 69 ), SubResource( 70 ), SubResource( 71 ), SubResource( 72 ), SubResource( 73 ), SubResource( 74 ), SubResource( 75 ), SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ), SubResource( 81 ), SubResource( 82 ), SubResource( 83 ), SubResource( 84 ), SubResource( 85 ), SubResource( 86 ), SubResource( 87 ), SubResource( 88 ), SubResource( 89 ), SubResource( 90 ), SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ), SubResource( 97 ), SubResource( 98 ), SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 104 ), SubResource( 105 ), SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 116 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ), SubResource( 123 ), SubResource( 124 ), SubResource( 125 ), SubResource( 126 ), SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ), SubResource( 133 ), SubResource( 134 ), SubResource( 135 ), SubResource( 136 ) ], "frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ), SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ), SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ), SubResource( 51 ), SubResource( 52 ), SubResource( 53 ), SubResource( 54 ), SubResource( 55 ), SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ), SubResource( 63 ), SubResource( 64 ), SubResource( 65 ), SubResource( 66 ), SubResource( 67 ), SubResource( 68 ), SubResource( 69 ), SubResource( 70 ), SubResource( 71 ), SubResource( 72 ), SubResource( 73 ), SubResource( 74 ), SubResource( 75 ), SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ), SubResource( 81 ), SubResource( 82 ), SubResource( 83 ), SubResource( 84 ), SubResource( 85 ), SubResource( 86 ), SubResource( 87 ), SubResource( 88 ), SubResource( 89 ), SubResource( 90 ), SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ), SubResource( 97 ), SubResource( 98 ), SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 104 ), SubResource( 105 ), SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 116 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ), SubResource( 123 ), SubResource( 124 ), SubResource( 125 ), SubResource( 126 ), SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ), SubResource( 133 ), SubResource( 134 ), SubResource( 135 ), SubResource( 136 ) ],
"loop": true, "loop": true,
"name": "default", "name": "idle",
"speed": 10.0 "speed": 10.0
} ] } ]

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://images/campfire/campfire.tres" type="SpriteFrames" id=1] [ext_resource path="res://images/campfire/campfire.tres" type="SpriteFrames" id=1]
[ext_resource path="res://images/campfire/ely.tres" type="SpriteFrames" id=2] [ext_resource path="res://images/campfire/ely.tres" type="SpriteFrames" id=2]
[ext_resource path="res://scenes/dialogue.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/dialogue.tscn" type="PackedScene" id=3]
[ext_resource path="res://scripts/scenes/IntroScript.gd" type="Script" id=4] [ext_resource path="res://scripts/scenes/IntroScript.gd" type="Script" id=4]
[ext_resource path="res://images/campfire/herbert_intro.tres" type="SpriteFrames" id=5] [ext_resource path="res://images/campfire/herbert_intro.tres" type="SpriteFrames" id=5]
[ext_resource path="res://sounds/BRS_Fire_Campfire_Busy_Crackles_Snaps_1.wav" type="AudioStream" id=6]
[node name="root" type="Node2D"] [node name="root" type="Node2D"]
@ -13,9 +14,13 @@ frames = ExtResource( 1 )
playing = true playing = true
centered = false centered = false
[node name="FireCrackles" type="AudioStreamPlayer" parent="Campfire (background)"]
stream = ExtResource( 6 )
autoplay = true
[node name="Ely" type="AnimatedSprite" parent="."] [node name="Ely" type="AnimatedSprite" parent="."]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
frame = 132 animation = "idle"
playing = true playing = true
centered = false centered = false
@ -34,6 +39,7 @@ __meta__ = {
[node name="Dialog" parent="UI" instance=ExtResource( 3 )] [node name="Dialog" parent="UI" instance=ExtResource( 3 )]
visible = false visible = false
audio_player_node_path = NodePath("../../AudioStreamPlayer")
[node name="IntroScript" type="Node" parent="."] [node name="IntroScript" type="Node" parent="."]
script = ExtResource( 4 ) script = ExtResource( 4 )
@ -41,3 +47,5 @@ dialogue_box_path = NodePath("../UI/Dialog")
ely_sprite_path = NodePath("../Ely") ely_sprite_path = NodePath("../Ely")
herbert_sprite_path = NodePath("../Herbert") herbert_sprite_path = NodePath("../Herbert")
intro_dialogue = "res://dialogues/intro_1.json" intro_dialogue = "res://dialogues/intro_1.json"
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]

View File

@ -13,6 +13,9 @@ onready var text_label = get_node(text_label_path) as RichTextLabel
export (NodePath) var expression_node_path export (NodePath) var expression_node_path
onready var expression_node = get_node(expression_node_path) as RichTextLabel onready var expression_node = get_node(expression_node_path) as RichTextLabel
export (NodePath) var audio_player_node_path
onready var audio_player_node = get_node(audio_player_node_path) as AudioStreamPlayer
var dialogue : Array var dialogue : Array
var index : int var index : int
@ -25,9 +28,10 @@ var auto_advance = false
func _ready(): func _ready():
assert(name_label != null) assert(name_label != null)
assert(text_label != null) assert(text_label != null)
assert(audio_player_node != null)
func start(dialogue : Array): func start(_dialogue : Array):
self.dialogue = dialogue dialogue = _dialogue
index = 0 index = 0
update() update()
@ -53,13 +57,24 @@ func update() -> void:
character_name = line.get('name', '') character_name = line.get('name', '')
text = line.get('text', '') text = line.get('text', '')
expression = line.get('expression', '') expression = line.get('expression', '')
# Flow
waiting = line.get('wait', false) waiting = line.get('wait', false)
var timer = line.get('timer', 0)
auto_advance = line.get('auto', false) auto_advance = line.get('auto', false)
# Timer
var timer = line.get('timer', 0)
if timer > 0: if timer > 0:
waiting = true waiting = true
# Audio
var audio = line.get('audio', '')
if audio != '':
var path = "res://sounds/" + audio + ".ogg"
assert(File.new().file_exists(path))
audio_player_node.stream = load(path)
audio_player_node.play()
# UI # UI
name_label.bbcode_text = character_name name_label.bbcode_text = character_name
name_label.rect_min_size.x = name_label.get_font('normal_font').get_string_size(name_label.text).x name_label.rect_min_size.x = name_label.get_font('normal_font').get_string_size(name_label.text).x

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/BRS_Fire_Campfire_Busy_Crackles_Snaps_1.wav-3b6264d1b3cb929e6463a3ee1df5b92a.sample"
[deps]
source_file="res://sounds/BRS_Fire_Campfire_Busy_Crackles_Snaps_1.wav"
dest_files=[ "res://.import/BRS_Fire_Campfire_Busy_Crackles_Snaps_1.wav-3b6264d1b3cb929e6463a3ee1df5b92a.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0

BIN
sounds/herbert_eyes.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/herbert_eyes.ogg-e5ba58e8ea4582e7811f5ffa2bcf2942.oggstr"
[deps]
source_file="res://sounds/herbert_eyes.ogg"
dest_files=[ "res://.import/herbert_eyes.ogg-e5ba58e8ea4582e7811f5ffa2bcf2942.oggstr" ]
[params]
loop=false
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/herbert_first_step.ogg-4321a1886697ba7710fbb81309548e61.oggstr"
[deps]
source_file="res://sounds/herbert_first_step.ogg"
dest_files=[ "res://.import/herbert_first_step.ogg-4321a1886697ba7710fbb81309548e61.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
sounds/herbert_is_happy.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/herbert_is_happy.ogg-d6cae557ce15ac28f03bfa7ebf789b37.oggstr"
[deps]
source_file="res://sounds/herbert_is_happy.ogg"
dest_files=[ "res://.import/herbert_is_happy.ogg-d6cae557ce15ac28f03bfa7ebf789b37.oggstr" ]
[params]
loop=true
loop_offset=0

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/herbert_second_step.ogg-5c328db0c5a075fbf08cc4da6533fa92.oggstr"
[deps]
source_file="res://sounds/herbert_second_step.ogg"
dest_files=[ "res://.import/herbert_second_step.ogg-5c328db0c5a075fbf08cc4da6533fa92.oggstr" ]
[params]
loop=false
loop_offset=0