fixed titlemenue, refactored soundplayback

This commit is contained in:
Streamfire
2020-04-19 21:10:56 +02:00
parent fb1599f55c
commit 3d6f8c6c2e
9 changed files with 73 additions and 76 deletions

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/menu_theme.ogg-9ccc235bdc65da3be6e74fbbdbbd5bce.oggstr"
[deps]
source_file="res://Menus/Sounds/menu_theme.ogg"
dest_files=[ "res://.import/menu_theme.ogg-9ccc235bdc65da3be6e74fbbdbbd5bce.oggstr" ]
[params]
loop=true
loop_offset=0

View File

@@ -1,33 +1,9 @@
extends AnimatedSprite
signal startup_finished
var finished_once := false
export(int) var startup_finish_frame = 65
export(int) var loop_frame = 80
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
play("default")
func _process(delta):
if Input.is_action_just_pressed("skip"):
frame = startup_finish_frame
if frame > startup_finish_frame:
if not finished_once:
emit_signal("startup_finished")
finished_once = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Startup_animation_finished():
frame = loop_frame

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=123 format=2]
[gd_scene load_steps=122 format=2]
[ext_resource path="res://Menus/Startup/Frames/LD46_50.jpg" type="Texture" id=1]
[ext_resource path="res://Menus/Startup/Frames/LD46_54.jpg" type="Texture" id=2]
@@ -120,18 +120,23 @@
[ext_resource path="res://Menus/Startup/Frames/LD46_98.jpg" type="Texture" id=118]
[ext_resource path="res://Menus/Startup/Frames/LD46_117.jpg" type="Texture" id=119]
[ext_resource path="res://Menus/Startup/Frames/LD46_116.jpg" type="Texture" id=120]
[ext_resource path="res://Menus/Startup/Startup.gd" type="Script" id=121]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 11 ), ExtResource( 17 ), ExtResource( 25 ), ExtResource( 10 ), ExtResource( 26 ), ExtResource( 37 ), ExtResource( 38 ), ExtResource( 18 ), ExtResource( 29 ), ExtResource( 14 ), ExtResource( 13 ), ExtResource( 27 ), ExtResource( 9 ), ExtResource( 28 ), ExtResource( 24 ), ExtResource( 32 ), ExtResource( 42 ), ExtResource( 23 ), ExtResource( 16 ), ExtResource( 20 ), ExtResource( 15 ), ExtResource( 7 ), ExtResource( 44 ), ExtResource( 35 ), ExtResource( 50 ), ExtResource( 33 ), ExtResource( 49 ), ExtResource( 41 ), ExtResource( 36 ), ExtResource( 39 ), ExtResource( 30 ), ExtResource( 12 ), ExtResource( 34 ), ExtResource( 22 ), ExtResource( 71 ), ExtResource( 31 ), ExtResource( 78 ), ExtResource( 45 ), ExtResource( 51 ), ExtResource( 55 ), ExtResource( 19 ), ExtResource( 43 ), ExtResource( 4 ), ExtResource( 52 ), ExtResource( 79 ), ExtResource( 60 ), ExtResource( 47 ), ExtResource( 56 ), ExtResource( 40 ), ExtResource( 21 ), ExtResource( 1 ), ExtResource( 57 ), ExtResource( 54 ), ExtResource( 6 ), ExtResource( 2 ), ExtResource( 5 ), ExtResource( 66 ), ExtResource( 58 ), ExtResource( 80 ), ExtResource( 46 ), ExtResource( 48 ), ExtResource( 53 ), ExtResource( 3 ), ExtResource( 76 ), ExtResource( 85 ), ExtResource( 77 ), ExtResource( 73 ), ExtResource( 61 ), ExtResource( 88 ), ExtResource( 64 ), ExtResource( 65 ), ExtResource( 89 ), ExtResource( 106 ), ExtResource( 99 ), ExtResource( 62 ), ExtResource( 104 ), ExtResource( 107 ), ExtResource( 95 ), ExtResource( 105 ), ExtResource( 86 ), ExtResource( 101 ), ExtResource( 72 ), ExtResource( 102 ), ExtResource( 75 ), ExtResource( 87 ), ExtResource( 70 ), ExtResource( 68 ), ExtResource( 103 ), ExtResource( 74 ), ExtResource( 69 ), ExtResource( 81 ), ExtResource( 82 ), ExtResource( 67 ), ExtResource( 59 ), ExtResource( 84 ), ExtResource( 83 ), ExtResource( 63 ), ExtResource( 109 ), ExtResource( 118 ), ExtResource( 93 ), ExtResource( 92 ), ExtResource( 91 ), ExtResource( 111 ), ExtResource( 108 ), ExtResource( 94 ), ExtResource( 96 ), ExtResource( 114 ), ExtResource( 97 ), ExtResource( 100 ), ExtResource( 110 ), ExtResource( 8 ), ExtResource( 90 ), ExtResource( 115 ), ExtResource( 98 ), ExtResource( 116 ), ExtResource( 117 ), ExtResource( 120 ), ExtResource( 119 ), ExtResource( 112 ), ExtResource( 113 ) ],
"loop": false,
"name": "start",
"speed": 12.0
}, {
"frames": [ ExtResource( 101 ), ExtResource( 72 ), ExtResource( 102 ), ExtResource( 75 ), ExtResource( 87 ), ExtResource( 70 ), ExtResource( 68 ), ExtResource( 103 ), ExtResource( 74 ), ExtResource( 69 ), ExtResource( 81 ), ExtResource( 82 ), ExtResource( 67 ), ExtResource( 59 ), ExtResource( 84 ), ExtResource( 83 ), ExtResource( 63 ), ExtResource( 109 ), ExtResource( 118 ), ExtResource( 93 ), ExtResource( 92 ), ExtResource( 91 ), ExtResource( 111 ), ExtResource( 108 ), ExtResource( 94 ), ExtResource( 96 ), ExtResource( 114 ), ExtResource( 97 ), ExtResource( 100 ), ExtResource( 110 ), ExtResource( 8 ), ExtResource( 90 ), ExtResource( 115 ), ExtResource( 98 ), ExtResource( 116 ), ExtResource( 117 ), ExtResource( 120 ), ExtResource( 119 ), ExtResource( 112 ), ExtResource( 113 ) ],
"loop": true,
"name": "default",
"name": "loop",
"speed": 12.0
} ]
[node name="Startup" type="AnimatedSprite"]
scale = Vector2( 1.4992, 1.5064 )
frames = SubResource( 1 )
speed_scale = 4.0
centered = false
script = ExtResource( 121 )
[connection signal="animation_finished" from="." to="." method="_on_Startup_animation_finished"]

View File

@@ -1,17 +1,37 @@
extends Control
class_name TitleScreen
onready var new_game_button = $"VBoxContainer/NewGameButton"
signal startup_finished
export(int) var startup_finish_frame = 65
export(int) var loop_frame = 80
onready var new_game_button = $VBoxContainer/NewGameButton
onready var animation_player = $AnimationPlayer
onready var startup= $Startup
var finished_once := false
func _ready():
startup.play("start")
animation_player.play("__INIT__")
SoundControler.pub_play_music("res://Menus/TitleScreen/title_screen_bgm.ogg", false)
SoundControler.pub_play_music("res://Menus/Sounds/menu_theme.ogg", false)
func _process(_delta):
if Input.is_action_just_pressed("skip"):
startup.frame = startup_finish_frame
if startup.frame > startup_finish_frame:
if not finished_once:
emit_signal("startup_finished")
new_game_button.ignore_once = true # Pauls russian solution for ignoring the first sound click in the titlescreen
new_game_button.grab_focus()
animation_player.play("show_buttons")
finished_once = true
func _exit_tree():
SoundControler.pub_stop_music()
func _on_Startup_startup_finished():
new_game_button.ignore_once = true # Pauls russian solution for ignoring the first sound click in the titlescreen
new_game_button.grab_focus()
animation_player.play("show_buttons")
func _on_Startup_animation_finished():
startup.play("loop")

View File

@@ -158,25 +158,31 @@ tracks/5/keys = {
[node name="TitleScreen" type="Control"]
anchor_left = -0.00168862
anchor_top = -0.003002
anchor_right = 0.998311
anchor_bottom = 0.996998
anchor_right = 0.704
anchor_bottom = 0.667
margin_left = 0.810538
margin_top = -0.18946
margin_right = -141.189
margin_bottom = -89.1895
margin_right = 0.0802612
margin_bottom = -0.0900574
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/__INIT__ = SubResource( 1 )
anims/show_buttons = SubResource( 2 )
[node name="Startup" parent="." instance=ExtResource( 2 )]
scale = Vector2( 1.50376, 1.50079 )
scale = Vector2( 1.50207, 1.49479 )
animation = "start"
speed_scale = 1.0
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.619068
anchor_top = 1.05219
anchor_right = 0.965944
anchor_bottom = 1.46586
anchor_left = 1.06328
anchor_top = 1.04447
anchor_right = 1.41015
anchor_bottom = 1.45814
margin_left = 1.52588e-05
__meta__ = {
"_edit_group_": true,
@@ -207,11 +213,7 @@ quit = true
[node name="Label" parent="VBoxContainer/QuitButton" index="0"]
text = "Quit"
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/__INIT__ = SubResource( 1 )
anims/show_buttons = SubResource( 2 )
[connection signal="startup_finished" from="Startup" to="." method="_on_Startup_startup_finished"]
[connection signal="animation_finished" from="Startup" to="." method="_on_Startup_animation_finished"]
[editable path="VBoxContainer/NewGameButton"]

View File

@@ -3,15 +3,10 @@ class_name TitleSceenButton
export(String, FILE, "*.tscn,*.scn") var scene_to_load = ""
export(bool) var quit = false
onready var sound_focus = $Sounds/FocusChange
onready var sound_select = $Sounds/OptionSelect
var ignore_once = false
func _pressed():
sound_select.play()
func _on_OptionSelect_finished():
SoundControler.pub_play_effect("res://Menus/Sounds/menu_option_select.ogg",0)
if quit:
get_tree().quit()
return
@@ -23,7 +18,8 @@ func _on_TitleScreenButton_mouse_entered():
grab_focus()
func _on_TitleScreenButton_focus_entered():
if not ignore_once:
sound_focus.play()
SoundControler.pub_play_effect("res://Menus/Sounds/menu_focus_change.ogg",0)
ignore_once = false

View File

@@ -1,9 +1,7 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Fonts/Harmonic/Harmonic24.tres" type="DynamicFont" id=1]
[ext_resource path="res://Menus/TitleScreen/TitleScreenButton.gd" type="Script" id=2]
[ext_resource path="res://Menus/Sounds/menu_focus_change.ogg" type="AudioStream" id=3]
[ext_resource path="res://Menus/Sounds/menu_option_select.ogg" type="AudioStream" id=4]
[node name="TitleScreenButton" type="Button"]
margin_right = 110.0
@@ -21,14 +19,5 @@ __meta__ = {
"_edit_use_anchors_": false,
"_editor_description_": ""
}
[node name="Sounds" type="Node" parent="."]
[node name="FocusChange" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource( 3 )
[node name="OptionSelect" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource( 4 )
[connection signal="focus_entered" from="." to="." method="_on_TitleScreenButton_focus_entered"]
[connection signal="mouse_entered" from="." to="." method="_on_TitleScreenButton_mouse_entered"]
[connection signal="finished" from="Sounds/OptionSelect" to="." method="_on_OptionSelect_finished"]

View File

@@ -1,12 +1,6 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
randomize()
pass # Replace with function body.