Hi guys
I’m trying to get some blocks to appear in random positions using predefined numbers.
At the moment, I have
-- Blocks
blocks = {1,2,3,4}
local r = math.random (1, #blocks )
local block1 = display.newImageRect("images/block1.png", 50, 50)
block1:setReferencePoint(display.CenterReferencePoint)
physics.addBody = "kinematic"
block1.name = "block"
block1.x = \_W \* 2
block1.y = \_H / blocks[r]
local block2 = display.newImageRect("images/block1.png", 50, 50)
block2:setReferencePoint(display.CenterReferencePoint)
physics.addBody = "kinematic"
block2.name = "block"
block2.x = \_W \* 3
block2.y = \_H / blocks[r]
What I’m trying to do is,
a) spawn a block
b) move it across the screen
c) when it reaches the end of the screen, remove it
d) spawn another block
e) repeat [import]uid: 40538 topic_id: 13369 reply_id: 313369[/import]