31 lines
903 B
GDScript
31 lines
903 B
GDScript
extends Node2D
|
|
|
|
func _ready():
|
|
var sectors = GameData.sectors # zakładam że GameData jest autoloadem
|
|
_spawn_sectors(sectors)
|
|
|
|
func _spawn_sectors(sectors: Array):
|
|
for sector in sectors:
|
|
var star = Sprite2D.new()
|
|
star.texture = sector.texture
|
|
star.position = sector.position
|
|
star.scale = Vector2(0.02, 0.02) # ewentualnie zmień skalę
|
|
add_child(star) # dodajemy bezpośrednio do Galaxy
|
|
|
|
# dodaj nazwę pod gwiazdą
|
|
var name_label = Label.new()
|
|
name_label.text = sector.name
|
|
name_label.position = star.position + Vector2(-20, 20)
|
|
add_child(name_label)
|
|
|
|
# dodaj nazwę pod gwiazdą
|
|
var name_label2 = Label.new()
|
|
name_label2.text = sector.id
|
|
name_label2.position = star.position + Vector2(-20, 40)
|
|
add_child(name_label2)
|
|
|
|
|
|
func _input(event):
|
|
if event.is_action_pressed("ui_cancel"): # "ui_cancel" to ESC
|
|
get_tree().change_scene_to_file("res://scenes/Menu.tscn")
|