Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Timer CoronasSDK-单击从场景中删除计时器_Timer_Lua_Coronasdk_Corona Storyboard - Fatal编程技术网

Timer CoronasSDK-单击从场景中删除计时器

Timer CoronasSDK-单击从场景中删除计时器,timer,lua,coronasdk,corona-storyboard,Timer,Lua,Coronasdk,Corona Storyboard,我有一个新的圆圈,当点击它时,会改变圆圈的颜色,并启动一个计时器。我希望能够再次单击圆圈,将其更改回黑色,并从场景中完全删除计时器 delta = 0 local function tapListener( event ) if (delta == 0) then c1:setFillColor(1,1,0) local timeLimit = 20 timeLeft = display.newText(timeLimit, c1.x,

我有一个新的圆圈,当点击它时,会改变圆圈的颜色,并启动一个计时器。我希望能够再次单击圆圈,将其更改回黑色,并从场景中完全删除计时器

delta = 0

local function tapListener( event )
    if (delta == 0) then
        c1:setFillColor(1,1,0)

        local timeLimit = 20
        timeLeft = display.newText(timeLimit, c1.x, c1.y, native.systemFontBold, 14)
        timeLeft:setTextColor(255,0,0)

        local function timerDown()
           timeLimit = timeLimit-1
           timeLeft.text = timeLimit
             if(timeLimit==0)then
                print("Time Out") -- or do your code for time out
             end
          end
        aTimer = timer.performWithDelay(1000,timerDown,timeLimit)            

        delta = delta + 1

    else 
        c1:setFillColor(0,0,0)

        delta = delta - 1


    end
答复:

else 
    c1:setFillColor(0,0,0)
    timer.cancel( aTimer )
    timeLeft.alpha = 0
    delta = delta - 1


end

timer.cancal(aTimer)
停止计时器,并且
timeLeft.aplha=0
隐藏显示计时器的文本

,同时很高兴知道您能够自己解决问题,但请在答案中包含更多信息。