7、Cocos2d-X 游戏编程之------CCControlSwitch的实现
2014-10-07 19:58
337 查看
7、CCControlSwitch的实现方法
boolHelloWorld::init()
{
if (!CCLayer::init() )
{
return false;
}
CCControlSwitch*pSwitch= CCControlSwitch::create(
CCSprite::create("switch-mask.png"),
CCSprite::create("switch-on.png"),
CCSprite::create("switch-off.png"),
CCSprite::create("switch-thumb.png"),
CCLabelTTF::create("开",
"Arial-BoldMT", 16),
CCLabelTTF::create("关",
"Arial-BoldMT", 16)
);
pSwitch->setPosition(ccp(200,200));
//设置关闭状态
pSwitch->setOn(false);
//设置可操作
pSwitch->setEnabled(true);
//获取是否为打开(on)
CCLOG("是否打开状态:%i",pSwitch->isOn());
//获取当前开关状态是否为手动拖动开关进行的
CCLOG("是否手动拖动的开关:%i",pSwitch->hasMoved());
addChild(pSwitch);
return true;
}
7、CCControlSwitch的实现方法
boolHelloWorld::init()
{
if (!CCLayer::init() )
{
return false;
}
CCControlSwitch*pSwitch= CCControlSwitch::create(
CCSprite::create("switch-mask.png"),
CCSprite::create("switch-on.png"),
CCSprite::create("switch-off.png"),
CCSprite::create("switch-thumb.png"),
CCLabelTTF::create("开",
"Arial-BoldMT", 16),
CCLabelTTF::create("关",
"Arial-BoldMT", 16)
);
pSwitch->setPosition(ccp(200,200));
//设置关闭状态
pSwitch->setOn(false);
//设置可操作
pSwitch->setEnabled(true);
//获取是否为打开(on)
CCLOG("是否打开状态:%i",pSwitch->isOn());
//获取当前开关状态是否为手动拖动开关进行的
CCLOG("是否手动拖动的开关:%i",pSwitch->hasMoved());
addChild(pSwitch);
return true;
}
相关文章推荐
- 8、Cocos2d-X 游戏编程之------CCControlSlider的使用
- 9、Cocos2d-X 游戏编程之------CCControlButton的使用
- Cocos2d—X游戏开发之CCToggle(菜单标签切换)CCControlSwitch(开关切换)(十二)
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- 详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- Cocos2d-x游戏开发之一 CCProgressTimer 生命条实现
- 我的Cocos2d-x学习笔记(十五)CCControlSlider、CCControlSwitch、CCScale9Sprite、CCControlButton
- cocos2d-x-2.0 新增UI的使用方法(CCControlSlider、CCControlSwitch、CCControlColourPicker、ListView)
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条实现“理想”游戏进度条! 推荐
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- Cocos2d-x_CCControlSwitch(开关类)介绍
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- 重新实现一遍cocos2d-x手机游戏编程一书中的魔塔源码
- Cocos2d-x控件使用CCControlSwitch<代码演示>
- Cocos2d-x 游戏开发之巧用CCDelayTIme实现多个action有序执行,使用CCCallFunc添加action回调
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- 详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- Cocos2D-x游戏开发之五:CCControlPotentiometer and CCControlSlider