Updated Hub World to have portals to levels and disabled the level select menu
This commit is contained in:
@@ -2,5 +2,16 @@ extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
|
||||
for level_portal in $'YSort/Level Portals'.get_children():
|
||||
if level_portal.connect('enter_level', self, 'enter_level') != OK:
|
||||
print('ERROR: Level Portal "enter_level" signal already connected.')
|
||||
return
|
||||
|
||||
|
||||
func enter_level(level: String) -> void:
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Hub World failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
|
File diff suppressed because one or more lines are too long
11
Levels/Interactables/Level Portal.gd
Normal file
11
Levels/Interactables/Level Portal.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Area2D
|
||||
|
||||
signal enter_level(level)
|
||||
|
||||
export var level_path: String = 'res://Levels/LEVEL.tscn'
|
||||
|
||||
|
||||
func _on_level_portal_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
emit_signal('enter_level', level_path)
|
||||
return
|
28
Levels/Interactables/Level Portal.tscn
Normal file
28
Levels/Interactables/Level Portal.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/Levels/Interactables/Level_Portal.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Levels/Interactables/Level Portal.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 8.0
|
||||
height = 18.0
|
||||
|
||||
[node name="Level Portal" type="Area2D"]
|
||||
light_mask = 0
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
input_pickable = false
|
||||
monitorable = false
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
offset = Vector2( 0, -8 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
light_mask = 0
|
||||
position = Vector2( 0, -8 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_level_portal_body_entered"]
|
Reference in New Issue
Block a user