[代码]
local buildingsA= getBuildings("level1a")
local buildingsB= getBuildings("level1b")
local buildingsC= getBuildings("level1c")
buildingsA.x=1100
buildingsB.x=buildingsA.x+buildingsA.width+300
buildingsC.x=buildingsB.x+buildingsB.width+350
--END OF LEVEL1 CREATION
timer.performWithDelay(1, function(e)
buildingsA.x = buildingsA.x -15
buildingsB.x = buildingsB.x-15
buildingsC.x = buildingsC.x-15
end, 0 )
function scrollblocks(self, event)
if self.x <-100 then
self.x=math.random(1200,2000)
end
end
buildingsA.enterFrame= scrollblocks
buildingsB.enterFrame= scrollblocks
buildingsC.enterFrame= scrollblocks
Runtime:addEventListener("enterFrame", buildingsA)
Runtime:addEventListener("enterFrame", buildingsB)
Runtime:addEventListener("enterFrame", buildingsC)
--Add hole
local hole = display.newImage("hole.png", true)
physics.addBody(hole, "static", {friction= 0.5, bounce=0})
hole.y=floor_bottom.y-60
hole.x= buildingsA.x+100
timer.performWithDelay(1, function(e)
hole.x= hole.x-15
end, 0 )
hole.enterFrame=scrollblocks
Runtime:addEventListener("enterFrame", hole)
[/代码]
我先生成建筑物,然后让它们慢慢地向左移动,然后从屏幕右侧随机生成,从而出现一个循环,建筑物从左到右出现。我对孔做同样的事情,但它们似乎与建筑物重叠。我如何限制它们重叠?