1、引入这个类:require "GuiConstants"
2、下面是回调函数的处理.
local function menuZhuCeCallback(sender,eventType)
print(sender:getTag())
if eventType == ccui.TouchEventType.began then
print("按下按钮")
elseif eventType == ccui.TouchEventType.moved then
print("按下按钮移动")
elseif eventType == ccui.TouchEventType.ended then
print("放开按钮")
elseif eventType == ccui.TouchEventType.canceled then
print("取消点击")
end
end
3 、对button事件的调用处理。获得button对象
local button_close=mianye:getChildByTag(4);
button_close:addTouchEventListener(menuZhuCeCallback)