How to make this spawn ‘math.random(1,3)’ smile.png every 10 seconds , and delete the smile.png after the left screen
[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 spawnsmile()
local smile = display.newImageRect(“smile.png”, 45, 45);
smile:setReferencePoint(display.CenterReferencePoint);
smile.x = math.random(-10, 400);
smile.y = -40;
transition.to( smile, {time = math.random(2000, 8000), x = math.random(-10, 400) , y = 600,});
physics.addBody(smile, “dynamic”, {density = 0.1, bounce = 0.1, friction = .1, radius = 0});
–Adding touch event
smile:addEventListener(“touch”, smile);
end
tmr = timer.performWithDelay(0, spawnsmile, total_smiles);
[code]
Regards Kevin [import]uid: 225288 topic_id: 35812 reply_id: 335812[/import]