1.
lua函式都在refid_fun
refid_fun[refid] = fun
tolua_api int toluafix_ref_function(lua_state* l, int lo, intdef)
staticint tolua_cocos2d_ccscripteventdispatcher_addnodeeventlistener00(lua_state*tolua_s) }
return1;
#ifndef tolua_release
tolua_lerror:
tolua_error(tolua_s,
"#ferror in function 'addnodeeventlistener'.
",&tolua_err);
return0;
#endif
}
比如;lua**item:addnodeeventlistener,ccscripteventdispatcher* self===item,int event===cc.menu_item_clicked_event,
lua_function listener =
function(tag)if sound then audio.playsound(sound) endlistener(tag)
end
--[[--建立一個文字標籤選單項,並返回 ccmenuitemlabel 物件。
可用引數:
- listener: **函式
- tag: 按鈕的 tag,會傳入**函式。多個按鈕使用同一個**函式時,可根據 tag 區分哪一個按鈕被按下(可選)
- x, y: 座標(可選)
以及所有可以用於 ui.newttflabel() 的引數。
@param table params 引數**物件
@return ccmenuitemlabel ccmenuitemlabel物件
]]function
ui.newttflabelmenuitem(params)
local p =clone(params)
p.x, p.y = nil, nil
local label =ui.newttflabel(p)
local listener =params.listener
local tag =params.tag
local x =params.x
local y =params.y
local sound =params.sound
local item =ccmenuitemlabel:create(label)
if item then
iftype(listener) == "
function
"then
item:addnodeeventlistener(cc.menu_item_clicked_event,
function
(tag)
if sound then audio.playsound(sound) end
listener(tag)
end)
endif x and y then item:setposition(x, y) end
if tag then item:settag(tag) end
endreturn
item
endself.item1 = ui.newttflabelmenuitem()
int ccluastack::executefunctionbyhandler(int nhandler, intnumargs)
ret =executefunction(numargs);
}return
ret;
}