hmm
This commit is contained in:
		
							parent
							
								
									05b6bdb73b
								
							
						
					
					
						commit
						8ec1ec6ac2
					
				| 
						 | 
				
			
			@ -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")
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
func on_scene_start():
 | 
			
		||||
	emit_signal("on_scene_start")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
> SET_BACKGROUND [INTRO_BG]
 | 
			
		||||
<BRAIN> ... You wake up to the sound of sirens blaring.
 | 
			
		||||
... maybe it's time to go to school?
 | 
			
		||||
> SWITCH_SCENE [FIRST_SCENE]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								game.gd
								
								
								
								
							
							
						
						
									
										15
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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" ]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue