diff --git a/common/scene.gd b/common/scene.gd index 9328f43..ba283c6 100644 --- a/common/scene.gd +++ b/common/scene.gd @@ -1,26 +1,13 @@ extends Node2D -var bg_sprite +onready var bg_sprite = get_node("background") signal on_scene_ready signal on_scene_start func _ready(): - - # internal state - var new_sprite = Sprite.new() - new_sprite.name = "background" - new_sprite.centered = false - add_child(new_sprite) - bg_sprite = new_sprite - - if not Game.game_started: - Game.game_started = true - emit_signal("on_scene_ready") - on_scene_start() - else: - emit_signal("on_scene_ready") - + Game.game_started = true + emit_signal("on_scene_ready") func on_scene_start(): emit_signal("on_scene_start") diff --git a/dialog/introduction.txt b/dialog/introduction.txt index 57d5c13..556d718 100644 --- a/dialog/introduction.txt +++ b/dialog/introduction.txt @@ -1,4 +1,3 @@ -> SET_BACKGROUND [INTRO_BG] ... You wake up to the sound of sirens blaring. ... maybe it's time to go to school? > SWITCH_SCENE [FIRST_SCENE] diff --git a/game.gd b/game.gd index 74da3aa..1ea72bf 100644 --- a/game.gd +++ b/game.gd @@ -75,11 +75,8 @@ func _set_background_fnc(args): func _switch_scene_fnc(args): if args.size() == 1: var scene_name = args[0] - transition.start_transition() - yield(transition, "on_transition_time") - SceneSwitcher.goto_scene(Scenes[scene_name]) - yield(transition, "on_transition_completed") - SceneSwitcher.current_scene.on_scene_start() + var scene_path = Scenes[scene_name] + switch_scene_to(scene_path) func _on_game_started_set(v): if v and not game_started: @@ -96,5 +93,13 @@ func _on_game_start(): _register_functions() +# public interface sorta +func switch_scene_to(scene_path): + transition.start_transition() + yield(transition, "on_transition_time") + SceneSwitcher.goto_scene(scene_path) + yield(transition, "on_transition_completed") + SceneSwitcher.current_scene.on_scene_start() + func _ready(): pass \ No newline at end of file diff --git a/menus/main_menu.gd b/menus/main_menu.gd index 5e29716..e032066 100644 --- a/menus/main_menu.gd +++ b/menus/main_menu.gd @@ -15,7 +15,7 @@ func _ready(): func _on_start_pressed(): - SceneSwitcher.goto_scene(Game.Scenes.INTRO) + Game.switch_scene_to(Game.Scenes.INTRO) func _on_load_pressed(): pass diff --git a/scenes/intro.tscn b/scenes/intro.tscn index 06d38b7..be492f0 100644 --- a/scenes/intro.tscn +++ b/scenes/intro.tscn @@ -1,24 +1,30 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://common/scene.gd" type="Script" id=1] -[ext_resource path="res://dialog_layer.gd" type="Script" id=2] -[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3] +[ext_resource path="res://img/intro_bg.png" type="Texture" id=2] +[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"] script = ExtResource( 1 ) -[node name="dialog_layer" type="CanvasLayer" parent="." index="0"] +[node name="background" type="Sprite" parent="." index="0"] + +texture = ExtResource( 2 ) +centered = false + +[node name="dialog_layer" type="CanvasLayer" parent="." index="1"] layer = 0 offset = Vector2( 0, 0 ) rotation = 0.0 scale = Vector2( 1, 1 ) transform = Transform2D( 1, 0, 0, 1, 0, 0 ) -script = ExtResource( 2 ) +script = ExtResource( 3 ) dialog_path = "res://dialog/introduction.txt" -[node name="dialog_box" parent="dialog_layer" index="0" instance=ExtResource( 3 )] +[node name="dialog_box" parent="dialog_layer" index="0" instance=ExtResource( 4 )] _sections_unfolded = [ "Visibility" ]