形状は画像の上部にあります。
http://picturepush.com/public/6472916
コードは次のようになります。
local xOffset = 0
for i = 1, levelPacks[prevCurrentLevelPack][prevCurrentLevel].ammount do
if i == 1 then --setup first one
shapesPrevArray[i].x = 30
shapesPrevArray[i].y = 41
shapesPrevArray[i].isVisible = true
end
if i > 1 then --setup the rest
--width of previous one plus the x value of the previous one to make them next to eachother.
xOffset = shapesPrevArray[i - 1].width + shapesPrevArray[i - 1].x
print("i:" .. i .. " width:" .. shapesPrevArray[i - 1].width .. " x value:" .. shapesPrevArray[i - 1].x .." xoffset:" .. xOffset)
shapesPrevArray[i].x = xOffset
shapesPrevArray[i].y = 41
shapesPrevArray[i].isVisible = true
xOffset = 0
end
end
配列内のすべての画像を、各画像間に同じスペースを空けて配置しようとしています。配列内の画像の幅が異なります。.x 値は、図形の左上隅にあります。どんな助けでも大歓迎です。