1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-11-24 17:14:22 +00:00
looping-for-loops/Objects/ScrollingObjects/Ghosts/GhostBlock.gd

32 lines
557 B
GDScript3
Raw Normal View History

2020-10-05 20:20:12 +00:00
extends KinematicBody2D
2020-10-04 18:26:45 +00:00
class_name GhostBlock
export(bool) var is_active: bool = true setget set_active
func _ready():
2020-10-05 20:20:12 +00:00
set_active_no_anim(is_active)
2020-10-04 18:26:45 +00:00
2020-10-05 20:20:12 +00:00
func set_active_no_anim(value):
2020-10-04 18:26:45 +00:00
$CollisionShape2D.disabled = not value
2020-10-05 20:20:12 +00:00
is_active = value
func set_active(value):
if not is_active and value:
$AnimationPlayer.play("Appear")
elif is_active and not value:
$AnimationPlayer.play_backwards("Appear")
set_active_no_anim(value)
2020-10-04 18:26:45 +00:00
func activate():
set_active(true)
func deactivate():
set_active(false)
func toggle():
set_active(not is_active)