lua中ccui.Button的創建和點擊方式


--ccui.Button的創建方法
ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
ccui.Button:create("crystal.png", "", "", ccui.TextureResType.plistType)

addClickEventListener(只在按鈕點擊觸發一次)

addTouchEventListener(按鈕點擊 抬起 移動 取消狀態觸發事件)

self:addTouchEventListener(function(sender, state)
local event = {x = 0, y = 0}
if state == 0 then
event.name = "began"
elseif state == 1 then
event.name = "moved"
elseif state == 2 then
event.name = "ended"
else
event.name = "cancelled"
end
event.target = sender
callback(event)
end)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM