car_select.gd 555 B

123456789101112131415161718192021222324252627282930313233
  1. extends Control
  2. # Member variables
  3. var town = null
  4. func _back():
  5. town.queue_free()
  6. show()
  7. func _load_scene(car):
  8. var tt = load(car).instance()
  9. tt.set_name("car")
  10. town = load("res://town_scene.tscn").instance()
  11. town.get_node("instance_pos").add_child(tt)
  12. town.get_node("back").connect("pressed", self, "_back")
  13. get_parent().add_child(town)
  14. hide()
  15. func _on_van_1_pressed():
  16. _load_scene("res://car_base.tscn")
  17. func _on_van_2_pressed():
  18. _load_scene("res://trailer_truck.tscn")
  19. func _on_van_3_pressed():
  20. _load_scene("res://crane.tscn")