feat: add switch node; add user interaction logic with signals to the switch node;
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
extends StaticBody2D
|
||||
|
||||
signal switch_activated
|
||||
signal switch_deactivated
|
||||
|
||||
var is_activated: bool = false
|
||||
var can_interact: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
$AnimatedSprite2D.play("deactivated")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("Interact") and can_interact:
|
||||
if !is_activated:
|
||||
$AnimatedSprite2D.play("activated")
|
||||
is_activated = true
|
||||
switch_activated.emit()
|
||||
else:
|
||||
$AnimatedSprite2D.play("deactivated")
|
||||
is_activated = false
|
||||
switch_deactivated.emit()
|
||||
Reference in New Issue
Block a user