继承关系
api文档地址:http://cn.cocos2d-x.org/doc/cocos2d-x-3.0/da/d32/classcocos2d_1_1extension_1_1_control.html
#include <CCControl.h>
类 Control 继承关系图:
![](http://cn.cocos2d-x.org/doc/cocos2d-x-3.0/da/d32/classcocos2d_1_1extension_1_1_control.png)
ControlSwitch:开关控件
ControlSlider:滑块控件
ControlButton:状态按钮控件
ControlSwitch
开关控件示例代码(基于Cocos2d-x2.1.5):
-- 振动
local shakeSwitch = nil
-- 回调
local function shakeCallback()
if shakeSwitch:isOn() then
cclog("open shake")
else
cclog("close shake")
end
end
shakeSwitch = CCControlSwitch:create(
-- 背景图片
CCSprite:create("res/ui/setting/switch-mask.png"),
-- 开启时背景
CCSprite:create("res/ui/setting/switch-on.pn