CCControlColourPicker学习笔记
2013-01-30 14:33
232 查看
我的cocos2d-x版本是2.1.0。CCControlColourPicker的源码我就直接贴这了,以后忘了的时候直接拿过来用就好,自己亲自测试,有问题请留言,谢谢。2d-x学习中。。。。。。。。。。。
CCControlColourPicker *colourPicker =
CCControlColourPicker::create();
colourPicker->setColor(ccc3(37,
46, 252));
colourPicker->setPosition(ccp (240,
160));
colourPicker->setBackground(CCSprite::create("HelloWorld.png"));
colourPicker->setEnabled(false);
// Add it to the layer
this->addChild(colourPicker);
//
// Add the target-action pair
colourPicker->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::colourValueChanged),
CCControlEventValueChanged);
回调函数
void
HelloWorld::colourValueChanged(CCObject *sender)
{
CCControlColourPicker* pPicker = (CCControlColourPicker*)sender;
std::string str =
CCString::createWithFormat("#%02X%02X%02X",pPicker->getColo
r().r, pPicker->getColor().g, pPicker->getColor().b)->getCString();
CCLog("CCControlColourPicker value = %s",str.c_str());
}
说一下我用的时候的问题,我第一次用的时候是把sample里边的extensions文件夹拖到项目资源中,然后将
CCControlColourPicker的cpp文件中
bool CCControlColourPicker::init()里边的资源名改掉才成功的,不知道有没有同样问题的原来的是
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist");
CCSpriteBatchNode *spriteSheet =
CCSpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png");
我修改为
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("CCControlColourPickerSpriteSheet.plist");
CCSpriteBatchNode *spriteSheet =
CCSpriteBatchNode::create("CCControlColourPickerSpriteSheet.png");
崩溃啊。。。。。。。。。
CCControlColourPicker *colourPicker =
CCControlColourPicker::create();
colourPicker->setColor(ccc3(37,
46, 252));
colourPicker->setPosition(ccp (240,
160));
colourPicker->setBackground(CCSprite::create("HelloWorld.png"));
colourPicker->setEnabled(false);
// Add it to the layer
this->addChild(colourPicker);
//
// Add the target-action pair
colourPicker->addTargetWithActionForControlEvents(this,
cccontrol_selector(HelloWorld::colourValueChanged),
CCControlEventValueChanged);
回调函数
void
HelloWorld::colourValueChanged(CCObject *sender)
{
CCControlColourPicker* pPicker = (CCControlColourPicker*)sender;
std::string str =
CCString::createWithFormat("#%02X%02X%02X",pPicker->getColo
r().r, pPicker->getColor().g, pPicker->getColor().b)->getCString();
CCLog("CCControlColourPicker value = %s",str.c_str());
}
说一下我用的时候的问题,我第一次用的时候是把sample里边的extensions文件夹拖到项目资源中,然后将
CCControlColourPicker的cpp文件中
bool CCControlColourPicker::init()里边的资源名改掉才成功的,不知道有没有同样问题的原来的是
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist");
CCSpriteBatchNode *spriteSheet =
CCSpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png");
我修改为
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("CCControlColourPickerSpriteSheet.plist");
CCSpriteBatchNode *spriteSheet =
CCSpriteBatchNode::create("CCControlColourPickerSpriteSheet.png");
崩溃啊。。。。。。。。。
相关文章推荐
- Cocos2d-x中颜色选择盘类CCControlColourPicker的使用
- cocos2d-x-2.0 新增UI的使用方法(CCControlSlider、CCControlSwitch、CCControlColourPicker、ListView)
- CCControlSwitch学习笔记
- 我的Cocos2d-x学习笔记(十五)CCControlSlider、CCControlSwitch、CCScale9Sprite、CCControlButton
- UI开发之控件类-CCControlColourPicker
- Cocos2d-x学习笔记(12)(CCControlSwitch开关、CCControlSlider滑动条、CCControlButton按钮)
- Cocos2d-x学习笔记(12)(CCControlSwitch开关、CCControlSlider滑动条、CCControlButtonbutton)
- CCControlExtension/CCControlColourPicker
- Cocos2d-x UI开发之CCControlColourPicker控件类使用实例
- CCControlPotentiometer旋转调节调节按钮学习笔记
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- cocos2d-x 菜鸟学习笔记八(界面控件之CCControl控件)
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- CCControlSlider滑动按钮学习笔记
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- CCControlButton学习笔记
- Swift学习笔记(4)使用UIImagePickerController实现从设备图片库和照相机获取图片
- 黑马程序员之C#学习笔记:break和continue的区别const与readonly的区别form与control的区别
- Cocos2dx 学习笔记28 使用CCCamera注意事项
- List Control & Tree Control & CImageCtrl 基本常规用法学习笔记