Godot Version
`Godot 4.2.2
Question
Firstly, I want to create drag and drop game. Therefore, I want the position of these texturerect change every time when start the game
I have 5 texturerect to be changed. How could I implement this?
`Godot 4.2.2
Firstly, I want to create drag and drop game. Therefore, I want the position of these texturerect change every time when start the game
I have 5 texturerect to be changed. How could I implement this?
You can do it like this:
func _ready():
for i in $HBoxContainer.get_children(): change_pos(i)
func change_pos(node):
randomize()
node.position = Vector2(randi_range(0, 1280), randi_range(0, 720))
Don’t call randomize unless you have a really good reason. It actually reduces the quality of your random numbers if you call it repeatedly like that.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.