how can i add +5 seconds in my timer down? using function ?


when i used this function, yes its works to plus 5 on the timilimit.

but the time was stop when the timelimit is equal to 5…

help pls… tnx.^^

 --> function plustime() – this is my function to add +5 seconds…

     timelitmit = timelimit + 5 

    timerdown.text = timelimit

    end


timeLimit = 20

timerdown = display.newText(timeLimit, 284, -33, “Arial”, 20)

timerdown:setTextColor(200,200,200)

    local function timerDown()

   timeLimit = timeLimit-1

   timerdown.text = timeLimit

     if timeLimit==0 then

print(“times up”)

   end

  end

timer1=timer.performWithDelay(1000,timerDown,timeLimit)

up

Not 100% sure what I understand. I think you want to modify the timeLimit while its counting down.

If so you need to put the timer.performWithDelay inside the timerDown function.

Runable example:

[lua]local timeLimit = 20

local function timerDown()

    print(timeLimit)

    timeLimit = timeLimit-1

    if timeLimit==0 then

        print(“times up”)

    else

        timer.performWithDelay(1000,timerDown)

    end

end

timerDown()

[/lua]

not working sir… error…

problem solve

up

Not 100% sure what I understand. I think you want to modify the timeLimit while its counting down.

If so you need to put the timer.performWithDelay inside the timerDown function.

Runable example:

[lua]local timeLimit = 20

local function timerDown()

    print(timeLimit)

    timeLimit = timeLimit-1

    if timeLimit==0 then

        print(“times up”)

    else

        timer.performWithDelay(1000,timerDown)

    end

end

timerDown()

[/lua]

not working sir… error…

problem solve