Hey guys i have a small and simple question how do i spawn random objects with this code
local physics = require (“physics”);
physics.start();
local function listener(me)
transition.to (me, {time = math.random(1000,4000), x = math.random(10,310), y = -30, onComplete = function()listener(me)end});
end
–Spawning multiple objects in randoms locations
local function spawnblcok()
local block = display.newImageRect(“block01.png”, 45, 45); – should i put a table here and make it pick a random block
block:setReferencePoint(display.CenterReferencePoint);
block.x = math.random(-10, 300);
block.y = -40;
transition.to( block, {time = math.random(2000, 8000), x = math.random(-10, 400) , y = 600,});
physics.addBody(block, “dynamic”, {density = 0.1, bounce = 0.1, friction = .1, radius = 0});
--Adding touch event
block:addEventListener(“touch”, block);
end
local total_block = 15
tmr = timer.performWithDelay(1000, spawnblcok, total_block);
also how do i make the block destroy their self when they past the bottom of the screen
thanks i really need this i think its easy to fix but i can’t crack it HELP THANKS AGAIN 