加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2dx 3.X Lua复选框的用法ccui.CheckBox

发布时间:2020-12-14 19:15:14 所属栏目:百科 来源:网络整理
导读:本文用的图片资源是采用官方test中的,可自行在cocos2dx引擎中搜索文件名找到该资源哦. 需要把函数写在前面,否则,后面调用的时候会说无法找到该函数,lua中提示函数为nil.... --响应事件函数 local function selectedEvent ( sender , eventType ) if eventTyp
本文用的图片资源是采用官方test中的,可自行在cocos2dx引擎中搜索文件名找到该资源哦.
需要把函数写在前面,否则,后面调用的时候会说无法找到该函数,lua中提示函数为nil....

--响应事件函数

localfunctionselectedEvent(sender,eventType)

ifeventType== ccui.CheckBoxEventType.selectedthen

cclog("eventType == ccui.CheckBoxEventType.selected "elseifeventType== ccui.CheckBoxEventType.unselected cclog("ccui.CheckBoxEventType.unselected unselected "end

end

--创建复选框

localcheckBox= ccui.CheckBox:create()

checkBox:setTouchEnabled(true)

checkBox:loadTextures("check_box_normal.png",

"check_box_normal_press.png""check_box_active.png""check_box_normal_disable.png""check_box_active_disable.png")

checkBox:setPosition(cc.p(120,300))--坐标

checkBox:addEventListenerCheckBox( selectedEvent) --注册事件
layerFarm:addChild(checkBox,10) -- 添加到图层

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读