0
我試圖做一個簡單的遊戲,但我有OME問題。 我有一個遊戲,有一個6個層的盒子,5秒後有另一個6個盒子的層等。 我的問題是,我想從每個圖層中刪除2個隨機框。在第一層中會有某種對象可以跳到盒子上,所以我想在第一層中移除2個盒子,並在其中放置一個對象,例如動物。這是我的代碼(這僅適用於箱的第一層,但是當我知道如何做到這一點也將在第二層上工作的第一層)Lua刪除板條箱
local physics = require("physics")
physics.start()
display.setDrawMode("hybrid")
local sky = display.newImage("bkg_clouds.png")
sky.x = display.contentWidth/2
sky.y = display.contentHeight/2-60
local ground = display.newImage("ground.png")
ground.x = display.contentWidth/2
ground.y = sky.y + display.contentHeight/2 + 80
ground.rotation = 0.7
local image_outline = graphics.newOutline(2, "ground.png")
physics.addBody(ground , "static", {friction = 0.5, bounce = 0.2, outline = image_outline})
local leftwall = display.newRect(0,0,1,display.contentHeight*2+100)
local rightwall = display.newRect(display.contentWidth,0,1,display.contentHeight*2+100)
physics.addBody(leftwall, "static",{bounce=0.1})
physics.addBody(rightwall, "static", {bounce = 0.1})
for i = 27, display.contentWidth-20, display.contentWidth/6 do
local crate = display.newImage("crate.png")
crate.x = i
crate.width = display.contentWidth/6.5
crate.y = 50
crate.height = display.contentWidth/6.5
physics.addBody(crate, {density = 3.0, friction = 0.5, bounce = 0.1})
end