目前用谷歌搜索自己疯了只是为了得到一个非常简单(我希望)的方法来访问两个或多个功能的答案EventListener
。
找到这个
local touchHandler = function(event)
if event.phase == "began" then
local t = event.target
print( "param1=" .. t.param1 .. ", param2=" .. t.param2 .. ", param3=" .. t.param3 )
end
end
local loadServerButton = display.newRect(0, 0, 50, 50)
loadServerButton:setFillColor(0, 0, 0)
loadServerButton.x= _W/2
loadServerButton.y= _H/1.35
loadServerButton.param1 = timestampWrite
loadServerButton.param2 = downloadServerAPI
loadServerButton.param3 = downloadUserAPI
loadServerButton:addEventListener("touch", touchHandler)
但是很难管理它的工作,通过接收 “运行时错误试图集中字段'param3'(一个函数值)”等等。
我究竟做错了什么?