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