Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Richard_A_Odell |
Test_level
Node2D (renamed Test_level) with script
const QBOX = preload(“res://Scene/QB.tscn”)
func _ready(delta):
if Global.qb:
var q = QBOX.instance()
add_child(q)
q.position.x = 1344
q.position.y = -136
Tilemap (draws the platforms)
SpongBob (the character/player)
Camer2D as a child of Spongbob
HUD with script
var banana = 0
onready var key = $Key
var haskey := false
func _ready():
$Coins.text = String(Global.coins)
loadhearts()
Global.hud = self
func loadhearts():
$HeartsFull.rect_size.x = Global.lives * 53
$HeartsEmpty.rect_size.x = 53
$HeartsEmpty.rect_position.x = $HeartsFull.rect_position.x + $HeartsFull.rect_size.x * $HeartsFull.rect_scale.x
func _on_coin_collected() → void:
Global.coins = Global.coins + 1
_ready()
func _on_random_coins() → void:
randomize()
var rv = randi()%50+1
Global.coins = Global.coins + rv
_ready()
in my test_level script it preloads QB
QBOX = preload(“res://Scene/QB.tscn”)
var q = QBOX.instance()
add_child(q)
q.position.x = 1344
q.position.y = -136
QB has a signal called random_coins()
on HUD i have
func _on_random_coins() → void:
so how do i connect the sign from the instance of QB.tscn to the function
on HUD called
func _on_random_coins() → void:
Why did you replicate this?
You already had an answer in the previous question.
zhyrin | 2023-03-06 10:31
it puts an error up
error(11,29): error parsing expression, misplaced: ‘<’
Richard_A_Odell | 2023-03-06 11:07
That is a syntax error, it has nothing to do with the originally asked question.
zhyrin | 2023-03-06 11:42
What is the actual problem?
SteveSmith | 2023-03-06 13:28