Godot Version
4.2
Question
can someone explain what am i do wrong with this?
and here is the code
@export var brick= preload(“res://brick.tscn”)
func _ready():
#this for getsize of the brick.
var test_brick = brick.instantiate() as Brick
add_child(test_brick)
var brick_size = test_brick.getsize()
test_brick.queue_free() #erase it after get size
var numrows = randi() % 5 #0 to 5
var numcolom = randi() % 6 +6 #6 to 12
for i in range(numrows):
for j in range(numcolom):
var copy = brick.instantiate()
copy.position = Vector2(j* brick_size.x, i * brick_size.y)
add_child(copy)