32 lines
989 B
GDScript
32 lines
989 B
GDScript
|
extends Node2D
|
||
|
|
||
|
onready var color_component = $Components/Color
|
||
|
onready var tinted_sprite_component = $Components/TintedSprite
|
||
|
onready var clickable_component = $Components/Clickable
|
||
|
onready var movable_component = $Components/Movable
|
||
|
|
||
|
onready var is_active = false
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
if color_component and tinted_sprite_component:
|
||
|
print ("Connecting signals")
|
||
|
color_component.connect("color_changed", tinted_sprite_component, "set_color_tint")
|
||
|
|
||
|
if clickable_component:
|
||
|
clickable_component.connect("clicked", self, "_on_entity_clicked")
|
||
|
|
||
|
|
||
|
func _process(delta):
|
||
|
if is_active and color_component:
|
||
|
var color = Color(
|
||
|
(sin(float(OS.get_system_time_msecs()) / 1000.0) + 1.0) / 2.0,
|
||
|
(sin(float(OS.get_system_time_msecs()) / 300.0) + 1.0) / 2.0,
|
||
|
(sin(float(OS.get_system_time_msecs()) / 100.0) + 1.0) / 2.0
|
||
|
)
|
||
|
color_component.set_color(color)
|
||
|
pass
|
||
|
|
||
|
func _on_entity_clicked():
|
||
|
is_active = not is_active
|