欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

Cocos2d-x UI開發(fā)之CCControlColourPicker控件類使用實(shí)例

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

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

bool HelloWorld::init()
{
  bool bRet = false;
  do
  {
    CC_BREAK_IF(! CCLayer::init());

		//設(shè)置一個(gè)顯示字符串的label
		CCLabelTTF * title = CCLabelTTF::create("#128128128","Arial",32);
		title->setPosition(ccp(240,280));
		//設(shè)置label的tag為1,方便以后獲取
		this->addChild(title,0,1);

		//這里有一個(gè)問題需要注意,在create之前,應(yīng)該在resource目錄下新建一個(gè)文件夾叫做extensions,然后把源代碼中
		//和CCControlColourPicker相關(guān)的資源導(dǎo)入進(jìn)去
		CCControlColourPicker * colorPicker = CCControlColourPicker::create();
		colorPicker->setColor(ccc3(128,128,128));

		//設(shè)置一張背景圖片,但是卻不起作用,至今沒解決,有誰解決了,說一聲
		//colorPicker->setBackground(CCSprite::create("HelloWorld.png"));

		//為colorPicker添加事件監(jiān)聽函數(shù)
		colorPicker->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::colorValueChanged),
  		CCControlEventValueChanged);

		//設(shè)置位置
		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,應(yīng)該用pPicker調(diào)用getColor函數(shù),但據(jù)本人查看他人的
	//博客,他們都是用的getColorValue函數(shù),他們應(yīng)該是早一點(diǎn)的版本
	title->setString(CCString::createWithFormat("#%03d%03d%03d",pPicker->getColor().r,pPicker->getColor().g,
		pPicker->getColor().b)->getCString());
 }

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有