Hai :3
I have a little problem with corona sdk…
I have writed some code…
How to make objects wich spawn to random position and move to random ?
Please help me
Hai :3
I have a little problem with corona sdk…
I have writed some code…
How to make objects wich spawn to random position and move to random ?
Please help me
There’s a ton of ways to do so, and it really depends on all the other factors in your game.
The example below uses transitions to move the objects to a random position, and a timer to spawn one object every second:
local function spawnObject() local xStart, yStart, xEnd, yEnd = math.random(10, 310), math.random(10, 470), math.random(10, 310), math.random(10, 470); local object = display.newCircle(xStart, yStart, 10); transition.to(object, {time = 500, x = xEnd, y = yEnd}); end timer.performWithDelay(1000, spawnObject, 0);
There’s a ton of ways to do so, and it really depends on all the other factors in your game.
The example below uses transitions to move the objects to a random position, and a timer to spawn one object every second:
local function spawnObject() local xStart, yStart, xEnd, yEnd = math.random(10, 310), math.random(10, 470), math.random(10, 310), math.random(10, 470); local object = display.newCircle(xStart, yStart, 10); transition.to(object, {time = 500, x = xEnd, y = yEnd}); end timer.performWithDelay(1000, spawnObject, 0);