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

29 lines
587 B
GDScript

extends Node2D
class_name GhostBlock
var active_sprite: Texture = preload("res://Sprites/ghost_block_active.png")
var inactive_sprite: Texture = preload("res://Sprites/ghost_block_inactive.png")
export(bool) var is_active: bool = true setget set_active
func _ready():
set_active(is_active)
func set_active(value):
is_active = value
$CollisionShape2D.disabled = not value
if value:
$Sprite.texture = active_sprite
else:
$Sprite.texture = inactive_sprite
func activate():
set_active(true)
func deactivate():
set_active(false)
func toggle():
set_active(not is_active)