1
루아 어를 배우고 있습니다. 나는 조금 혼란 스럽다. timer.PerformWithDelay 메서드를 통해 함수에 인수를 전달하려고합니다. 여기에 내가 쓴 코드는 다음과 같습니다timer.PerformWithDelay - Lua를 통해 인수 전달
local function animate (event)
gear.rotation = gear.rotation + rotateAmount;
end
Runtime:addEventListener("enterFrame", animate);
------------------------------------------------
function reverseRotate()
if tonumber(rtAm) > 0 then -- here appear error: "Attempt to compare number with nil"
rotateAmount = rotateAmount - 1;
elseif tonumber(rtAm) < 0 then
rotateAmount = rotateAmount + 1;
end
end
------------------------------------------------
local buttonHandler = function (event)
if event.phase == "ended" then
local iteration = math.abs(rotateAmount);
if rotateAmount > 0 then
local rtAm = rotateAmount;
timer.performWithDelay(100, function() reverseRotate ("rtAm") end, 2*iteration);
elseif rotateAmount < 0 then
local rtAm = rotateAmount;
timer.performWithDelay(100, function() reverseRotate ("rtAm") end, 2*iteration);
end
end
end
그래서 내 질문은 왜 rtAm이 reverseRotation 함수에 전달되지 않은 변수?
'기능 reverseRotate (rtAm) 대괄호 ... 또한 docs에서 인용 부호를 다시 썼습니다 : D Silly meeeee. 감사합니다 Egor! –
내가 라운드에서 rtAm를 추가하는 것을 잊었다 end' 경우
– Neru@EgorSkriptunoff 답변 섹션에 의견을 게시하십시오. 네루, 한번 대답 해주세요. –