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]