2015-04-04 62 views
0

我有一個newCircle,當點擊改變圓的顏色,並啓動一個計時器吧。我希望能夠再次點擊圓圈並將其改回黑色,並完全從場景中移除定時器。CoronaSDK - 從點擊刪除定時器從現場點擊

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 

回答

-1

答案:

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


end 

timer.cancal(aTimer)停止計時器和timeLeft.aplha = 0隱藏正在顯示計時器

+0

雖然這是好事,知道你能夠自行解決問題的文本,但請在答案中加入一些信息。 – hjpotter92 2015-04-04 14:36:35