瀏覽代碼

Make players appear on arena spawners

DricomDragon 5 年之前
父節點
當前提交
554205f325
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      Game.gd

+ 7 - 3
Game.gd

@@ -33,6 +33,7 @@ func start():
 		for p in players:
 			p.queue_free()
 	if (levelCurrentNode):
+		remove_child(levelCurrentNode)
 		levelCurrentNode.queue_free()
 
 	# Select level
@@ -48,6 +49,9 @@ func start():
 	levelCurrentNode = levelScenes[levelIndex].instance()
 	add_child(levelCurrentNode)
 
+	# Retrieve player spawn points
+	var spawners = get_tree().get_nodes_in_group("spawn")
+
 	# Create players
 	var player
 
@@ -56,7 +60,7 @@ func start():
 	player.grid = levelCurrentNode
 	player.turn_left_action = "p1_left"
 	player.turn_right_action = "p1_right"
-	player.position = Vector2(4 * 64 + 32, 8 * 64 + 32)
+	player.position = spawners[0].position
 	add_child(player)
 
 	# Player 2
@@ -64,7 +68,7 @@ func start():
 	player.grid = levelCurrentNode
 	player.turn_left_action = "p2_left"
 	player.turn_right_action = "p2_right"
-	player.position = Vector2(6 * 64 + 32, 8 * 64 + 32)
+	player.position = spawners[1].position
 	add_child(player)
 
 	# Player 3
@@ -72,7 +76,7 @@ func start():
 	player.grid = levelCurrentNode
 	player.turn_left_action = "p3_left"
 	player.turn_right_action = "p3_right"
-	player.position = Vector2(8 * 64 + 32, 8 * 64 + 32)
+	player.position = spawners[2].position
 	add_child(player)
 
 	# TODO Timer