cocos2dx 3.X Lua复选框的用法ccui.CheckBox
本文用的图片资源是采用官方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)
--
添加到图层
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |