2015-07-05 22 views
-2

我想模擬西蒙說遊戲。我目前使用Corona SDK,並使用Lua作爲我的語言。爲什麼這段代碼不能啓動?

我已經把addEventListener(touch)放在函數「開始」上。我已經試過調試它,並且它似乎代碼沒有正確運行說,if (started) then聲明的部分。如果你們能夠幫助我走向正確的方向,我將非常感激!

這裏是我的代碼部分:

local function starting(event) 

    if (started == false) then 
     started = true 
    end 


    if (event.phase == "ended") then 
     start() 
     startText.isVisible = false 
--------------------------------------------------- 
--THIS BELOW PART IS WRONG-- does not do "started" 

     if (started) then 

      count = count + 1 


      --if started-- 
      if(math.mod(count,20) == 0) then 
       clicked = 0 

       if(light >= 0) then 
        light = light - 1 
       end 

      end 
+0

「不正確運行」是什麼意思?你初始化了嗎? – ryanpattison

+0

只是初始化開始=零或假。 –

+0

錯誤可能會比零更好。但它並不重要 –

回答

1

確保已初始化開始像rpattiso提到假。同樣在我過去的經歷中,有時只是把if (started) then 不適合我,所以你應該試試if (started == true) then

相關問題