Home > Database > Mysql Tutorial > cocos2dx 3.X Lua复选框的用法ccui.CheckBox

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:09:31
Original
2699 people have browsed it

--响应事件函数 local function selectedEvent ( sender , eventType ) if eventType == ccui.CheckBoxEventType.selected then cclog( eventType == ccui.CheckBoxEventType.selected ) elseif eventType == ccui.CheckBoxEventType.unselected then cclog(

--响应事件函数

local function selectedEvent(sender,eventType)

    if eventType == ccui.CheckBoxEventType.selected then

        cclog("eventType == ccui.CheckBoxEventType.selected  ")

    elseif eventType == ccui.CheckBoxEventType.unselected then

        cclog("ccui.CheckBoxEventType.unselected  unselected  ")

     end

 end   

--创建复选框         

local checkBox = 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(120300))   --坐标

checkBox:addEventListenerCheckBox(selectedEvent)  --注册事件

layerFarm:addChild(checkBox,10)  --添加到图层

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template