Hi everyone!
I’m new to programming with corona and i’m trying to make this code work and it does but i have some problems with putting it into composer, hope someone can give me an advice!
local barriere = {}
local function creaBarriere(event)
local barriera
barriera = display.newImageRect(fg,“transenna2.png”,1000,1000)
–corpo fisico degli ostacol
barriera.x = 1380+math.random(50,300)
barriera.y = display.contentHeight+400
physics.addBody(barriera,“static”,{density=3.0, shape=formaBarriere,bounce=0.0})
barriera.name=“barriera”
barriera:toFront()
table.insert(barriere,barriera)
return barriera
end
local formaBarriere = {50,-200,200,300,-200,300}
local function barrierScroll(self,event)
local speed_3 = 30
self.x =self.x - speed_3
end
local function gameLoop()
local barriera = creaBarriere()
barriera.enterFrame = barrierScroll
Runtime:addEventListener(“enterFrame”, barriera)
print(#barriere)
for i,thisBarrier in ipairs(barriere) do
if thisBarrier.x < -80 then
Runtime:removeEventListener(“enterFrame”,thisBarrier)
display.remove(thisBarrier)
table.remove(barriere,i)
end
end
end
local gameLoopTimer = timer.performWithDelay(2000,gameLoop,0)