How can i change the position of a panel?

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

I create a Panel at runtime using this code:

var tempPanel =

then i want to change the position of the Panel. I tried this:

tempPanel.position = Vector2(x, y) # Where x and y are forloop variables.

But then i get this error:

Invalid set index ‘position’ (on base: ‘Panel’) with value of type ‘Vector2’

Maybe you could help me with this?

:bust_in_silhouette: Reply From: Jayman2000

Node2Ds have a position property. Your code doesn’t work because a Panel isn’t a Node2D. Panels are Controls. Controls have similar property called rect_position.

tempPanel.rect_position = Vector2(x, y)

Thanks alot, that worked flawless!

YAGU | 2021-03-05 09:24