【发布时间】:2011-11-10 07:13:48
【问题描述】:
形状位于图像的顶部。
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 值位于形状的左上角。任何帮助将不胜感激。
【问题讨论】:
-
看起来这段代码会将形状彼此相邻放置,它们之间没有空格。屏幕截图中不是这种情况。每个形状只是白色部分,还是还包括一些黑色?
-
您好,感谢您的回复,形状不是图像文件,它们是通过设置宽度和高度值定义的矩形。然后我将其缩小一半。所以不应该有黑色!
-
要么,要么 .width 没有正确初始化......
标签: arrays image lua spacing lua-table