How can I draw in a for loop?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaaaxiKing

Doing this just draws one circle and everyhing else disappears.

extends Control

var array = ["7b5454","7f4444","402828","6e4040","603e3e","7d4242","644242","623d3d","6f3737"]

func _draw():
	for color in array:
		var myToolButton = ToolButton.new()
		myToolButton.align = 2
		myToolButton.text = "#" + color
		myToolButton.size_flags_vertical = 1
		myToolButton.rect_min_size = Vector2(125,50)
		$VBoxContainer.add_child(myToolButton)
		draw_circle(Vector2(myToolButton.rect_position) + Vector2(30/2, 30/2), 30, color)

What do I have to do?

I noticed, it has to do something with the shader I have put on two Sprites in this scene. It is by GDQuest https://www.youtube.com/watch?v=LAa8UE3ItM8

MaaaxiKing | 2020-06-04 11:49

:bust_in_silhouette: Reply From: LoneDespair

they are probably overlapping?

extends Control

var array = [“7b5454”,“7f4444”,“402828”,“6e4040”,“603e3e”,“7d4242”,“644242”,“623d3d”,“6f3737”]

func _draw():
| var Pos := Vector2.ZERO
| for color in array:
| | var myToolButton = ToolButton.new()
| | myToolButton.align = 2
| | myToolButton.text = “#” + color
| | myToolButton.size_flags_vertical = 1
| | myToolButton.rect_min_size = Vector2(125,50)
| | Pos += Vector2(40, 0)
| | #$VBoxContainer.add_child(myToolButton)
| | draw_circle(Pos, 30, color)

Now I have all circles, nevertheless everything else which could be seen in the scene is away.

MaaaxiKing | 2020-05-24 14:24