diff --git a/core/sceneInstance.gd b/core/sceneInstance.gd index 0a3700d..c4a16af 100644 --- a/core/sceneInstance.gd +++ b/core/sceneInstance.gd @@ -5,31 +5,21 @@ extends Node2D @onready var current_scene = $CurrentScene #@onready var scene_transition = $ScreenTransition/AnimationPlayer -var next_scene = null - var player -var player_location : Vector2 = Vector2(0,0) -var player_direction : float = 1 - - -func transition_to_scene(new_scene: PackedScene, spawn_location:Vector2, spawn_direction:float ): - next_scene = new_scene - player_location = spawn_location - player_direction = spawn_direction +func transition_to_scene(new_scene: PackedScene, spawn_location = Vector2(0,0), spawn_direction = 1): #screen_transition.play('FadeToBlack') if(current_scene.get_child(0)): current_scene.get_child(0).queue_free() - current_scene.add_child(next_scene.instantiate()) + current_scene.add_child(new_scene.instantiate()) #region Spawn Player - if (player): - player.teleport(player_location, player_direction) + player.teleport(spawn_location, spawn_direction) else: player = $CurrentScene.find_child("player",true) if (player): - player.teleport(player_location, player_direction) + player.teleport(spawn_location, spawn_direction) else: if (InitialPlayer): player = InitialPlayer.instantiate() @@ -37,9 +27,7 @@ func transition_to_scene(new_scene: PackedScene, spawn_location:Vector2, spawn_d add_child(player) else: printerr("No Initial player found") - #endregion - func _on_ready(): transition_to_scene(InitialMap,Vector2(0,0),1)