嘿所以我一直试图弄清楚这一点,但没有运气。我有8个随机洗牌的产卵,他们应该产卵两行4。我遇到的问题是,所有8似乎只产卵在第一排。传播对象 - 科罗娜SDK
所以基本上这样:
[1] [2] [3] [4] [5] [6] [7] [8]
[] [] [] []
当它应该是这样的:
[1] [2] [3] [4]
[5] [6] [7] [8]
我理解它的事实,我定位每个球体在做以Y轴为中心,但不知道该怎么做,这样如果4个位置被占用,然后向下移动到第二行。
干杯,
菌种代码
function spawnBase()
shuffleOrbArray(orbList)
for i=1, #orbList do
local orbName = orbList[i]
local posX = (i-1)*67+60
if orbName == "red" then
redPlace = display.newImageRect("Shapes/red-placeholder.png", 57,57)
redPlace.y = _H/2
redPlace.x = posX
redPlace.alpha = 1
redPlace.id = "Red"
orbName:insert(redPlace)
redPlace:addEventListener("tap", revealColor)
elseif orbName == "green" then
--create green enemy
greenPlace = display.newImageRect("Shapes/green-placeholder.png", 57,57)
greenPlace.y = _H/2
greenPlace.x = posX
greenPlace.alpha = 1
greenPlace.id = "Green"
orbName:insert(greenPlace)
greenPlace:addEventListener("tap", revealColor)
elseif orbName == "yellow" then
--create green enemy
什么是'_H/2'吗? – hjpotter92
噢,对此感到抱歉。 _H/2基本上是display.content高度除以2.它意味着中心高度。 –
您可以更新'i> 4'的这个值。 – hjpotter92