20 lines
547 B
GDScript
20 lines
547 B
GDScript
# Plik: res://scripts/Star.gd
|
|
extends Node2D
|
|
class_name Star
|
|
|
|
# Brak zagnieżdżonej klasy. Dane będą przypisane z GameData
|
|
var data = null
|
|
|
|
@onready var sprite: Sprite2D = $Sprite2D
|
|
|
|
func _ready():
|
|
# Oczekujemy, że węzeł, który nas instancjonuje, przypisze 'data'
|
|
_apply_visuals()
|
|
|
|
func _apply_visuals():
|
|
# Sprawdza, czy 'data' jest obiektem i ma ścieżkę do tekstury
|
|
if is_instance_valid(data) and data.texture_path != "":
|
|
var star_texture = load(data.texture_path)
|
|
if star_texture and sprite:
|
|
sprite.texture = star_texture
|