Add a level 2 scaffold and make the level-clear screen load the next level
level_clear.gd gained a next_level_scene export: empty reloads the current level, otherwise it changes to the given scene. Level 1 now points at res://scenes/level_2.tscn. level_2.tscn is an empty but complete level: background, three TileMapLayers wired to the same TileSet, player, HUD, death screen and level-clear screen, plus the empty prefab containers. Its hidden_passages script explicitly sets hidden_cells = [] so level 1's passage cells are not carved here.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
uid://dbjrrn5xe6nbh
|
||||
@@ -0,0 +1 @@
|
||||
uid://dr3fyoan8fwhj
|
||||
@@ -6,6 +6,9 @@ extends CanvasLayer
|
||||
|
||||
@export var fade_time: float = 0.8
|
||||
@export var button_delay: float = 0.3
|
||||
## 点「进入下一关」时加载哪个场景。
|
||||
## 留空 = 重新加载本关;填 res://scenes/level_2.tscn 之类就跳到下一关。
|
||||
@export_file("*.tscn") var next_level_scene: String = ""
|
||||
|
||||
var _fade: ColorRect = null
|
||||
var _center: CenterContainer = null
|
||||
@@ -29,6 +32,8 @@ func _ready() -> void:
|
||||
_fade.color = Color(0.0, 0.0, 0.0, 0.0)
|
||||
if _center != null:
|
||||
_center.visible = false
|
||||
if next_level_scene.is_empty() and _button != null:
|
||||
_button.text = "重新开始 (R)"
|
||||
|
||||
|
||||
func show_clear() -> void:
|
||||
@@ -65,8 +70,9 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
next_level()
|
||||
|
||||
|
||||
## 目前项目里只有一关,所以"下一关"先做成重新加载本关。
|
||||
## 以后真加了第二关,把这里换成 change_scene_to_file("res://scenes/level2.tscn") 即可。
|
||||
func next_level() -> void:
|
||||
get_tree().paused = false
|
||||
get_tree().reload_current_scene()
|
||||
if next_level_scene.is_empty():
|
||||
get_tree().reload_current_scene()
|
||||
else:
|
||||
get_tree().change_scene_to_file(next_level_scene)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://cxfohn44nkm28
|
||||
Reference in New Issue
Block a user