Help to recognize spawned objects

hey guys, I’m trying to make all gears rotate at same time but
only the last rotates, I need tome idea to recognize every gear spawned.
Sorry for the english

[applescript]
local gear = 0
gameover = 0
time = 5
local timertxt = display.newText(time,0,0, native.systemFont, 16*2)
timertxt.xscale = .5
timertxt.yscale = .5
timertxt.x = display.contentWidth/2
timertxt.y = display.contentHeight - 50
function timercount()
if (gameover == 0) then
time=time-1
timertxt.text = time
if(time == 0) then
gameoverfunc()
end
end
end

function spawn()
gear = display.newImage(“gear.png”)
randx = math.random(320)
randy = math.random(600)
gear.x = 100+randx
gear.y = 100+randy
function rotate(event)
if (gameover == 0) then
gear.rotation = gear.rotation + 10
end
end

function remover(obj)
obj:removeSelf()
end

function gear:touch(event)
if (gameover == 0) then
remover(self)
end
end
gear:addEventListener( “touch”, gear)
local rotate = timer.performWithDelay( 1, rotate, 5000 )
end
local spawn = timer.performWithDelay( 20, spawn, 20)
local timercount = timer.performWithDelay( 1000, timercount, 20)
function gameoverfunc()
gameover=1
timertxt.text = “”
gametxt = display.newText(“Game Over”,0,0, native.systemFont, 16*2)
gametxt.xscale = .5
gametxt.yscale = .5
gametxt.x = display.contentWidth/2
gametxt.y = display.contentHeight - 50
end

[/applescript] [import]uid: 54253 topic_id: 9154 reply_id: 309154[/import]

You may want to try taking a look at this; http://developer.anscamobile.com/reference/index/objectrotate

Or, alternatively, check out the Polyline app. (You can find it in the Corona Sample Code folder on your computer.) [import]uid: 52491 topic_id: 9154 reply_id: 33389[/import]

[code]
local gear = 0
gameover = 0
time = 5

local timertxt = display.newText(time,0,0, native.systemFont, 16*2)
timertxt.xscale = .5
timertxt.yscale = .5
timertxt.x = display.contentWidth/2
timertxt.y = display.contentHeight - 50

function timercount()
if (gameover == 0) then
time=time-1
timertxt.text = time
if(time == 0) then
gameoverfunc()
end
end
end

function spawn()
gear = display.newImage(“gear.png”)
randx = math.random(220)
randy = math.random(380)
gear.x = 100+randx
gear.y = 100+randy

–Added this enterFrame to keep track of gears and removed your rotate function
function gear:enterFrame(event)
self.rotation = self.rotation + 10
if (gameover ~= 0) then
Runtime:removeEventListener(“enterFrame”, self);
end
end

function remover(obj)
obj:removeSelf()
end

function gear:touch(event)
if (gameover == 0) then
Runtime:removeEventListener(“enterFrame”, self);
remover(self)
end
end

gear:addEventListener( “touch”, gear)

–Added this enterFrame to keep track of gears
Runtime:addEventListener(“enterFrame”, gear);

end

function gameoverfunc()
gameover=1
timertxt.text = “”
gametxt = display.newText(“Game Over”,0,0, native.systemFont, 16*2)
gametxt.xscale = .5
gametxt.yscale = .5
gametxt.x = display.contentWidth/2
gametxt.y = display.contentHeight - 50
end

local spawn = timer.performWithDelay( 20, spawn, 20)
local timercount = timer.performWithDelay( 1000, timercount, 0)
[/code] [import]uid: 2245 topic_id: 9154 reply_id: 33445[/import]