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)
学习如春起之苗,不见其增日有所长。辍学如磨刀之石,不见其损年有所亏。

浙公网安备 33010602011771号