Im trying to make a brick fall from the sky and a player would have to avoid it…right now I am spawning a new brick at a random point and applying physics to it so it falls, but the main character of my game is effected by physics in the x direction which changes based on the accelerometer. This isnt working now because the bricks are falling at an angle based on the accelerometer too…
I want to spawn the object, and then make it move down on the screen.
My problem with getting this to work is that i think I would need two functions…One to make them spawn(at a delay of 5000), and another to make it move down (using object.y = object.y - 1)with no delay. When I do this, it does not work though.
Here is my code now(with the physics, not the two function approach):
local function updateBlocks()
check = math.random(640)
brick1 = display.newImage(“brick.png”, check, 0, true)
brick = display.newImage(“brick.png”, check, -500, true)
physics.addBody(brick)
end
timer.performWithDelay(5000, updateBlocks, -1)
Thanks