godot_experiments/experiments/psd_panel_ui.gd

42 lines
1.2 KiB
GDScript3
Raw Normal View History

2024-04-19 13:15:35 +08:00
@tool
extends Node2D
var stationLabelNode: PackedScene = preload("res://experiments/station_label.tscn")
class StationLable:
var name: String
var enName: String
var current: bool
func _init(n, en, cur):
name = n
enName = en
current = cur
var stations = [
StationLable.new("会展中心", "Exhibition Center", true),
StationLable.new("世纪大道", "Century Avenue", false),
StationLable.new("交通大学", "JiaoTong Univercity", false),
StationLable.new("市图书馆", "City Library", false),
StationLable.new("中心医院", "Central Hospital", false),
StationLable.new("未来路", "Wei lai lu", false),
StationLable.new("火车站", "train station", false),
StationLable.new("人民广场", "People's Square", false),
StationLable.new("体育中心", "sports center", false),
]
var reverseStations = stations.reverse()
func _ready():
print(stationLabelNode)
for i in stations.size():
var slable = stations[i]
print(slable.name, slable.enName, slable.current)
if slable.current:
$VBoxContainer/CurrentStationName.text = slable.name
$VBoxContainer/EnName.text = slable.enName
var slScene = stationLabelNode.instantiate()
slScene._init_station_name_and_position(slable.name, slable.enName, i)
$Container.add_child(slScene)