func spawnCircle(): #Spawn circle at random position every 3 seconds
var circle = TextureButton.new()
var texture = load("res://Assets/Circle.png")
circle.set_normal_texture(texture)
circleSpawnTimer.start(2.5) #spawn next circle
randomize()
add_child(circle)
circle.rect_position.x = randi() % int(rect_size.x)
circle.rect_position.y = randi() % int(rect_size.y)
circle.connect("pressed", self, "on_Circle_pressed", [circle]) #connect circle pressed signal and pass in its reference
var circleDisappearTimer = Timer.new() #Timer for circles to disappear if left unclicked
circle.add_child(circleDisappearTimer)
circleDisappearTimer.connect("timeout", circle, "queue_free") #delete circle on timeout
circleDisappearTimer.start(4) #After 5seconds left unclicked , the circle will disappear
I have a circle clicker game, everything seems to be working correctly except that the circles sometimes spawn at the edge of the screen, making it only half-visible or only a a quarter of it visible. How do I make it so the circle only spawn at places that allows it to be fully visible?
tree_enteredto a script that positions it. - Theraot