6
Atama işlevini oluştururken, "if" koşulu çalışmıyor ancak aşağıdaki ikinci örnekte olduğu gibi işlev oluşturduğumda çalışır. Nedenini söyler misin?Lua'da işlev oluşturma
Çalışmıyor:
local start=os.time()
local countDown = function(event)
if((os.time()-start)==3) then
Runtime: removeEventListener("enterFrame", countDown)
end
print(os.time()-start)
end
Runtime:addEventListener("enterFrame", countDown)
Çalışma:
Eğerlocal countDown = ...
, ne zaman
countDown
değişken
...
parçası çalıştırıldıktan sonra
kadar var olmadığından değil
local start=os.time()
local function countDown(event)
if((os.time()-start)==3) then
Runtime: removeEventListener("enterFrame", countDown)
end
print(os.time()-start)
end
Runtime:addEventListener("enterFrame", countDown)