NODE_PADDING = 100
self = {}
self.rows = 3
self.cols = 3
local offsetX = -math.floor(NODE_PADDING * self.cols / 2) - NODE_PADDING / 2
local offsetY = -math.floor(NODE_PADDING * self.rows / 2) - NODE_PADDING / 2
-- create board, place all coins
for row = 1, self.rows do
local y = row * NODE_PADDING + offsetY
for col = 1, self.cols do
local x = col * NODE_PADDING + offsetX
print(x, y)
end
end
输出
-100 -100
0 -100
100 -100
-100 0
0 0
100 0
-100 100
0 100
100 100