GodotCourse/examples/PlatformTemplate/scripts/gamecontroller.gd

33 lines
784 B
GDScript3
Raw Normal View History

2024-07-15 12:00:42 +00:00
extends Node2D
# call downward, signal upward
@onready var block = $Node2D
var boxInstance = preload("res://scenes/rigidbody.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_trigger_one_areatrigger(effect, body):
match effect:
"unlock":
if !body.is_in_group("boxes"):
if is_instance_valid(block):
block.queue_free()
"boxdrop":
# make some boxes
# ensure boxes do not trigger trap!
if!body.is_in_group("boxes"):
for n in 3:
var mybox = boxInstance.instantiate()
mybox.add_to_group("boxes")
mybox.position = Vector2(465,23)
add_child(mybox)