timer y contador

mi juego se trata de un montón de bolitas que caen, tu las explotas al tocar,pero no se cual seria el código para que hubiera un cronometro y si explotas todas las bolitas antes del tiempo ganas,si no las explotas pierdas… también me gustaría que al reventar un pelota de ten punto este es mi código.

saludos desde venezuela soy un principiante

[code]
–set music
local pop_sound = audio.loadSound(“pop.mp3”)
– add physics engine, start up the engine, and apply gravity
local physics = require(“physics”)
physics.start()
– Set gravity to act “down” (ie, toward the bottom of the device )
physics.setGravity (0.1)
–set background image
local background = display.newImage( “background.jpg” )
–set wall image and position
local wall= display.newImage(“bara.png”)
wall.x = display.contentWidth/95
–turn wall into physics body
physics.addBody(wall,“static”)
–set wally image and position
local wally = display.newImage(“bara.png”)
wally.x = display.contentWidth/1
–turn wally into physics body
physics.addBody(wally,“static”)
–add floor image and position
local floor = display.newImage(“bar.png”)
floor.y = display.contentHeight/1.03
– turn floor into physics body
physics.addBody(floor,“static”)

local function trackBalls (obj)
obj:removeSelf()
end

–set ball to stage and position
local function spawnBall()
local ball =display.newImage(“bead2.png”)
ball.x = math.random ( 320 )
ball.y = -100

– turn ball into physics body
physics.addBody(ball,{ bounce = 0.2 , friction = 5} )

function ball:touch(e)
if(e.phase == “ended”) then
–Play the popping sound
audio.play(pop_sound);
–remove the balls
trackBalls(self);
end

return true;

end

ball:addEventListener(“touch”, ball) ;

end

timer.performWithDelay( 100,spawnBall,10) [import]uid: 179948 topic_id: 31600 reply_id: 331600[/import]