[Resolved] error with timer

i am following this tutorial http://www.youtube.com/watch?v=6TsDdLY7VXk (with some changes that i made ) and all was fine until he put little code of timer . and in he’s simulator the timer work and i my simulator didn’t work this is my code sorry for the bad english i hope you can help me

[code]

o = 0;
time_remain = 10;
time_up = false;
ready =false
total_balls = 25
–set music
local pop_sound = audio.loadSound(“pop.mp3”)

local display_txt = display.newText(“Wait”, 0, 0, native.sistemFont, 16*2);
display_txt.xScale = .5; display_txt.yScale = .5;
display_txt:setReferencePoint(display.bottomLeftReferencePoint);
display_txt.x = 20; display_txt.y = display.contentHeight-20;

local countdowntxt = display.newText(time_remain, 0, 0, native.systemFont, 16*2);
countdowntxt.xScale = .5; countdowntxt.yScale = .5 ;
countdowntxt:setReferencePoint(display.BottomRigthReferencePoint) ;
countdowntxt.x = display.contentWidth-20; countdowntxt.y = display.contentHeight-20;

– 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, 9)
–set wall image and position
local wall= display.newImage(“bara.png”)
wall.x = display.contentWidth/99,9
–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
– turn floor into physics body
physics.addBody(floor,“static”)

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

local function countDown(e)
time_remain = time_remain-1;
countdown.text = time_remain;
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.1 } )

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

return true;

end
–increment o for every ball created
o = o+1;

ball:addEventListener(“touch”, ball) ;

–if all balls created, start the game timer
if(o == total_balls) then
gametmr = timer.performWithDelay(1000, countDown, 10 );
end

end

timer.performWithDelay( 25,spawnBall,total_balls) [import]uid: 179948 topic_id: 31640 reply_id: 331640[/import]

Are you getting an error on this in the terminal? You should be - line 50;
[lua]countdown.text = time_remain[/lua]
Should be;
[lua]countdowntxt.text = time_remain;[/lua]

Let me know if that helps.

Peach :slight_smile: [import]uid: 52491 topic_id: 31640 reply_id: 126437[/import]

thanks it work perfect thanks peach [import]uid: 179948 topic_id: 31640 reply_id: 126446[/import]

No worries, happy to help :slight_smile: Marking as resolved. [import]uid: 52491 topic_id: 31640 reply_id: 126593[/import]

Are you getting an error on this in the terminal? You should be - line 50;
[lua]countdown.text = time_remain[/lua]
Should be;
[lua]countdowntxt.text = time_remain;[/lua]

Let me know if that helps.

Peach :slight_smile: [import]uid: 52491 topic_id: 31640 reply_id: 126437[/import]

thanks it work perfect thanks peach [import]uid: 179948 topic_id: 31640 reply_id: 126446[/import]

No worries, happy to help :slight_smile: Marking as resolved. [import]uid: 52491 topic_id: 31640 reply_id: 126593[/import]