@TwistedTwigleg said:
If the nodes are Control-based, then you can use something like this to set the center position of node:
func set_control_center(control_node, center_point):
control_node.rect_global_position = center_point - (control_node.rect_size * 0.5)
The reason you need to subtract half the rectangle size is because the position for Control nodes are in the upper left corner, so the offset needs to be added manually.
Then once you have the function above defined, you can set the position using something like:
# for example
set_control_center($Control, Vector2(300, 300))
How does it give the centre's location to all surrounding buttons?
I did this which isn't very good because it has fixed coordinates (which I gathered from the creation of the center button) but works.
const spawnarray:Array=[[25, 25], [100, 25], [175, 25], [250, 25], [325, 25], [400, 25], [475, 25], [550, 25], [625, 25], [25, 100], [100, 100], [175, 100], [250, 100], [325, 100], [400, 100], [475, 100], [550, 100], [625, 100], [25, 175], [100, 175], [175, 175], [250, 175], [325, 175], [400, 175], [475, 175], [550, 175], [625, 175], [25, 250], [100, 250], [175, 250], [250, 250], [325, 250], [400, 250], [475, 250], [550, 250], [625, 250], [25, 325], [100, 325], [175, 325], [250, 325], [325, 325], [400, 325], [475, 325], [550, 325], [625, 325], [25, 400], [100, 400], [175, 400], [250, 400], [325, 400], [400, 400], [475, 400], [550, 400], [625, 400], [25, 475], [100, 475], [175, 475], [250, 475], [325, 475], [400, 475], [475, 475], [550, 475], [625, 475], [25, 550], [100, 550], [175, 550], [250, 550], [325, 550], [400, 550], [475, 550], [550, 550], [625, 550], [25, 625], [100, 625], [175, 625], [250, 625], [325, 625], [400, 625], [475, 625], [550, 625], [625, 625]]
var sa:Array
var sax:float
var say:float
var spawnlocn:Vector2
func init(num,_x,_y,_tileid,_squ,_tilesize):
sa=spawnarray[_tileid]
sax=float(sa[0])
say=float(sa[1])
spawnlocn=Vector2 (sax,say)