Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Richard_A_Odell |
the root is Swim_demo
Platforms
Area2D
Door
Key
Exit
HUD
COINS/coin1 coin2
Adventure(camer2D)
COCONUTS/coconut
Swim_demo Script
onready var coconuts = 0
onready var hud2 = preload(“res://Scene/HUD2.tscn”)
func _on_Blue_key_body_entered(body):
$Door/Blue_door.queue_free()
$Key/Blue_key.queue_free()
func _on_Gold_key_body_entered(body):
$Door/Gold_door.queue_free()
$Key/Gold_key.queue_free()
add_hud()
remove_hud()
func _on_Green_key_body_entered(body):
$Door/Green_door.queue_free()
$Key/Green_key.queue_free()
func _on_Orange_key_body_entered(body):
$Door/Orange_door.queue_free()
$Key/Orange_key.queue_free()
func remove_hud():
$HUD.queue_free()
func add_hud():
var h = hud2.instance()
add_child(h)
coin1 (and coin2) script
signal coin_collected
func _on_coin_body_entered(body):
$AnimationPlayer.play(“bounce”)
emit_signal(“coin_collected”)
set_collision_mask_bit(0, false)
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free()
coconut script
signal coconut_collected
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free()
func _on_CoCONUT_body_entered(body):
$AnimationPlayer.play(“bounce”)
emit_signal(“coconut_collected”)
set_collision_mask_bit(0, false)
HUD 2 script
var coconuts = 0
var rng = RandomNumberGenerator.new()
func _ready():
$Coconut.text = String(coconuts)
func _physics_process(delta):
if coconuts == 3:
pass
func _on_coconut_collected():
coconuts = coconuts + 1
_ready()
here is what i need help with (please please include code)
so far i have $COCONUTS/coconut1.connect(“coconut_collected”)
i have tried every way i can think to get to the _on_coconut_collected (which is in HUD script)