bogdan,
This example is a quick fix, and I tried to keep as much of your code as it was, but several parts had to be changed to get this to function. I only am trying to show what you requested, that is, how to spawn the objects one a time.
I set up a timer in the movement function you had, so every 3 seconds an obj will spawn. But, also, a simple rectangle at the top of the screen if you touch it it will spawn an object also.
Cut and paste this code into a new project into your corona and try it out. It is very crude and simple, and not the way I would do my project, but it shows what you are looking for. Play around with changing parts of the code and that is a good way to learn how it all works.
Note: I use local in front of all the functions, you had yours as global, and that is not normally recommended.
Note: I added a flag ‘isdone’ to each object so you can deactivate the object once it should no longer be moving.
Note: I made ‘obj’ local in the ‘spawn’ function
Good luck.
local score = 0 local spawnCnt = 0 local spawnTable = {} local startTime = os.time() local function spawn () local obj = display.newImageRect("Icon.png",70,70) obj.x = 100 obj.y = 300 obj.isDone = false return obj end local function onSpawn () spawnCnt = spawnCnt + 1 spawnTable[spawnCnt] = spawn() end local function onTouch(e) if e.phase == "ended" then onSpawn() end end local rect = display.newRect(100,100,50,50) rect:addEventListener("touch", onTouch) local function movement (event) -- SPAWN OBJECT USING TIMER if os.time() - startTime \>= 3 then onSpawn() startTime = os.time() end -- MOVE OBJECT if spawnCnt \> 0 then for i = 1, spawnCnt do if spawnTable[i].isDone == false then if spawnTable[i].x \< -20 then spawnTable[i].x = 300 spawnTable[i].isDone = true else spawnTable[i].x = spawnTable[i].x - 2 end end end end end Runtime:addEventListener ("enterFrame",movement)