options menu start

This commit is contained in:
Robin Hübner 2018-09-21 20:39:08 +02:00
parent c64a7aee5d
commit 6ecd0a57b1
5 changed files with 55 additions and 8 deletions

32
game.gd
View File

@ -11,6 +11,10 @@ var current_registry
onready var music_player = get_node("music_player")
onready var sfx_player = get_node("sfx_player")
var master_vol setget _on_set_master_vol
var music_vol setget _on_set_music_vol
var sfx_vol setget _on_set_sfx_vol
# transition node
onready var transition = get_node("trans_layer/transition")
@ -46,6 +50,7 @@ const Scenes = {
# MENUS
MAIN_MENU = "res://menus/main_menu.tscn",
OPTIONS_MENU = "res://menus/options_menu.tscn",
# GAME
INTRO = "res://scenes/intro.tscn",
@ -84,6 +89,15 @@ func _on_game_started_set(v):
_on_game_start()
game_started = v
func _on_set_master_vol(v):
pass
func _on_set_music_vol(v):
pass
func _on_set_sfx_vol(v):
pass
func _on_game_start():
# all game state here
@ -94,13 +108,19 @@ func _on_game_start():
# public interface sorta
func switch_scene_to(scene_path):
transition.start_transition()
yield(transition, "on_transition_time")
func switch_scene_to(scene_path, fade = true):
if fade:
transition.start_transition()
yield(transition, "on_transition_time")
SceneSwitcher.goto_scene(scene_path)
yield(transition, "on_transition_completed")
if SceneSwitcher.current_scene.has_method("on_scene_start"):
SceneSwitcher.current_scene.on_scene_start()
if fade:
yield(transition, "on_transition_completed")
if SceneSwitcher.current_scene.has_method("on_scene_start"):
SceneSwitcher.current_scene.on_scene_start()
func _ready():
pass

View File

@ -21,7 +21,7 @@ func _on_load_pressed():
pass
func _on_options_pressed():
pass
Game.switch_scene_to(Game.Scenes.OPTIONS_MENU, false)
func _on_quit_pressed():
get_tree().quit()

6
menus/options_menu.gd Normal file
View File

@ -0,0 +1,6 @@
extends Control
var from_scene_name
func _ready():
pass

21
menus/options_menu.tscn Normal file
View File

@ -0,0 +1,21 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://menus/options_menu.gd" type="Script" id=1]
[node name="options_menu" type="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 40.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 1 )

View File

@ -5,7 +5,7 @@
[ext_resource path="res://dialog_layer.gd" type="Script" id=3]
[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=4]
[node name="intro" type="Node2D" index="0"]
[node name="intro" type="Node2D"]
script = ExtResource( 1 )