对触摸按钮事件有四种状态,忘记取消在按钮上滑动的状态,导致一个bug
local function myCallback(sender,eventType)
print(sender:getTag())
if eventType == ccui.TouchEventType.began then
print("this is touch began......)
elseif eventType == ccui.TouchEventType.ended then
print("this is touch ended......)
elseif eventType == ccui.TouchEventType.moved then
print("this is touch Moved ......)
elseif eventType == ccui.TouchEventType.canceled then
print("this is touch Moved canceled ......)
end
end
local btn = rootNode:getChildByName("Rbt")
:addTouchEventListener(myCallback)
本文介绍了一个关于触摸按钮事件处理的实例。文章详细解释了四种触摸事件:开始(began)、结束(ended)、移动(moved)及取消(canceled),并通过示例代码展示了如何通过Lua脚本语言使用Cocos2d-x UI库来实现这些事件的监听。
1349

被折叠的 条评论
为什么被折叠?



