嘿所以我一直試圖弄清楚這一點,但沒有運氣。我有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