Hi, I am new to Corona and was wandering how to do something which is similar to Falldown (but will have a different purpose). So far I have:
local function createNewFloors() randomno = math.random (display.contentWidth/4, display.contentWidth\*3/4) -- random width of left floor, from 1/4 to 3/4 of the screen width floorR = display.newImage("floorRR.png", 0 , -60) floorL = display.newImage("floorLL.png", 0 , -60) floorR.anchorX = 0 --reference X at left of floorR floorL.anchorX = 1 --reference X at right of floorL floorL.x = randomno floorR.x = randomno+30 physics.addBody(floorL, {density = 99999}) -- not static or they won't move physics.addBody(floorR, {density = 99999}) -- high density or the ball will affect its movement floorL:setLinearVelocity(0,-50)-- so the floors go up floorR:setLinearVelocity(0,-50) timer.performWithDelay (1500, createNewFloors) end Runtime:addEventListener("enterFrame", createNewFloors)
So basicly, it will create FloorLL and the left side and FloorRR on the right side but in random places, but it has a 30pixel or more gap imbetween. However, all this does is create about 1 floor every 0.5 of a second and spamms it without it being static so it falls. Can anyone help? Thanks