国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

Cocos2d-x UI開發之CCControlColourPicker控件類使用實例

2020-01-26 15:19:50
字體:
來源:轉載
供稿:網友

CCControlColourPicker實現顏色拾取器的功能。關于控件使用時的一些配置,請參見文章:UI開發之控件類-CCControlButton。下邊來看源代碼。

bool HelloWorld::init(){  bool bRet = false;  do  {    CC_BREAK_IF(! CCLayer::init());		//設置一個顯示字符串的label		CCLabelTTF * title = CCLabelTTF::create("#128128128","Arial",32);		title->setPosition(ccp(240,280));		//設置label的tag為1,方便以后獲取		this->addChild(title,0,1);		//這里有一個問題需要注意,在create之前,應該在resource目錄下新建一個文件夾叫做extensions,然后把源代碼中		//和CCControlColourPicker相關的資源導入進去		CCControlColourPicker * colorPicker = CCControlColourPicker::create();		colorPicker->setColor(ccc3(128,128,128));		//設置一張背景圖片,但是卻不起作用,至今沒解決,有誰解決了,說一聲		//colorPicker->setBackground(CCSprite::create("HelloWorld.png"));		//為colorPicker添加事件監聽函數		colorPicker->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::colorValueChanged),  		CCControlEventValueChanged);		//設置位置		colorPicker->setPosition(ccp(240,160));		this->addChild(colorPicker);    bRet = true;  } while (0);  return bRet;}void HelloWorld::colorValueChanged(CCObject * pSender,CCControlEvent controlEvent) {	CCLabelTTF * title = (CCLabelTTF *)this->getChildByTag(1);	CCControlColourPicker * pPicker = (CCControlColourPicker *)pSender;	//這里需要注意了,本人用的cocos2d-x的版本是2.2,應該用pPicker調用getColor函數,但據本人查看他人的	//博客,他們都是用的getColorValue函數,他們應該是早一點的版本	title->setString(CCString::createWithFormat("#%03d%03d%03d",pPicker->getColor().r,pPicker->getColor().g,		pPicker->getColor().b)->getCString()); }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 平江县| 泰安市| 长汀县| 易门县| 苏尼特右旗| 当雄县| 徐水县| 南澳县| 荔浦县| 辉南县| 乐安县| 高清| 高平市| 城固县| 论坛| 云安县| 清远市| 临武县| 陕西省| 邵阳市| 岱山县| 山阳县| 磐安县| 全南县| 汶川县| 景谷| 黄石市| 玉环县| 福贡县| 通州区| 盐津县| 兴宁市| 黄冈市| 晴隆县| 越西县| 江西省| 永善县| 田阳县| 芮城县| 确山县| 阳春市|