feat: add sceneManager; add playerSpawnPos to sceneEntrance and sceneManager; update player node to use value from sceneManager; make sceneManager autoloaded;
This commit is contained in:
@@ -2,6 +2,17 @@
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://5viursrnvdyf" path="res://Scenes/Player/player.tscn" id="1_okyhq"]
|
||||
[ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="1_xuufh"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_sx8ki"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6f4q3"]
|
||||
texture = ExtResource("3_sx8ki")
|
||||
0:7/size_in_atlas = Vector2i(3, 3)
|
||||
0:7/0 = 0
|
||||
3:7/size_in_atlas = Vector2i(3, 3)
|
||||
3:7/0 = 0
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_bqpwv"]
|
||||
sources/0 = SubResource("TileSetAtlasSource_6f4q3")
|
||||
|
||||
[node name="DungeonScene" type="Node2D" unique_id=1981353208]
|
||||
|
||||
@@ -11,5 +22,10 @@
|
||||
zoom = Vector2(5, 5)
|
||||
|
||||
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("1_xuufh")]
|
||||
position = Vector2(0, 30)
|
||||
position = Vector2(42, 1)
|
||||
next_scene = "res://Scenes/GameScene/game_scene.tscn"
|
||||
player_spawn_pos = Vector2(137, -91)
|
||||
|
||||
[node name="ObstacleLayer" type="TileMapLayer" parent="." unique_id=1536979901]
|
||||
tile_map_data = PackedByteArray(0, 0, 2, 0, 255, 255, 0, 0, 3, 0, 7, 0, 0, 0)
|
||||
tile_set = SubResource("TileSet_bqpwv")
|
||||
|
||||
@@ -7,7 +7,7 @@ class_name Player
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var damage: float = 2
|
||||
print(damage)
|
||||
position = SceneManager.player_next_scene_spawn_pos
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Area2D
|
||||
@export var next_scene: String
|
||||
@export var player_spawn_pos: Vector2
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -13,6 +14,7 @@ func _process(delta: float) -> void:
|
||||
|
||||
func _on_body_entered(body: Player) -> void:
|
||||
print("body entered!")
|
||||
$"/root/SceneManager".player_next_scene_spawn_pos = player_spawn_pos
|
||||
get_tree().change_scene_to_file.call_deferred(next_scene)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
var player_next_scene_spawn_pos: Vector2
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://bghfl5hagv6q1
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://6txu74mchftj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bghfl5hagv6q1" path="res://Scenes/SceneManager/scene_manager.gd" id="1_car14"]
|
||||
|
||||
[node name="SceneManager" type="Node2D" unique_id=402183888]
|
||||
script = ExtResource("1_car14")
|
||||
Reference in New Issue
Block a user