【发布时间】:2011-05-17 23:08:06
【问题描述】:
我是 Lua 的新手,所以(很自然地)我在尝试编程的第一件事上就卡住了。我正在使用 Corona Developer 软件包提供的示例脚本。这是我试图调用的函数的简化版本(删除了不相关的材料):
function new( imageSet, slideBackground, top, bottom )
function g:jumpToImage(num)
print(num)
local i = 0
print("jumpToImage")
print("#images", #images)
for i = 1, #images do
if i < num then
images[i].x = -screenW*.5;
elseif i > num then
images[i].x = screenW*1.5 + pad
else
images[i].x = screenW*.5 - pad
end
end
imgNum = num
initImage(imgNum)
end
end
如果我尝试这样调用该函数:
local test = slideView.new( myImages )
test.jumpToImage(2)
我收到此错误:
尝试将数字与 nil 进行比较
在第 225 行。似乎“num”没有被传递到函数中。这是为什么呢?
【问题讨论】: