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

cocos2dx 3.X Lua复选框的用法ccui.CheckBox,第1张

概述本文用的图片资源是采用官方test中的,可自行在cocos2dx引擎中搜索文件名找到该资源哦. 需要把函数写在前面,否则,后面调用的时候会说无法找到该函数,lua中提示函数为nil.... --响应事件函数 local function selectedEvent(sender,eventType)     if eventType == ccui.CheckBoxEventType.select 本文用的图片资源是采用官方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) -- 添加到图层 总结

以上是内存溢出为你收集整理的cocos2dx 3.X Lua复选框的用法ccui.CheckBox全部内容,希望文章能够帮你解决cocos2dx 3.X Lua复选框的用法ccui.CheckBox所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1006410.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存