我有以下功能
不工作:
local function onPlayBtnRelease(level)
storyboard.gotoScene( level, "fade", 500 )
return true
end
我想传递一个参数以便加载适当的级别,所以我有以下按钮:
planet1 = widget.newButton{
label="1",
labelColor = { default={255}, over={128} },
fontSize=25,
defaultFile="levelplanet.png",
overFile="levelplanet-over.png",
width=62, height=62,
onRelease = onPlayBtnRelease("loadscene1") -- event listener function
}
但以上不起作用。
那没问题:
如果我做
local function onPlayBtnRelease
storyboard.gotoScene( "loadscene1", "fade", 500 )
return true
end
planet1 = widget.newButton{
label="1",
labelColor = { default={255}, over={128} },
fontSize=25,
defaultFile="levelplanet.png",
overFile="levelplanet-over.png",
width=62, height=62,
onRelease = onPlayBtnRelease
}
它编译。如何将参数传递给onPlayBtnRelease
?知道为什么这会导致编译错误吗?
错误:
Runtime error
bad argument #1 to 'find' (string expected, got table)
stack traceback:
[C]: ?
[C]: in function 'error'
?: in function 'gotoScene'