亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2014年09月11日 10:37:10   作者:皂莢花  
這篇文章主要介紹了Cocos2d-x UI開發(fā)之CCControlSwitch控件類使用實(shí)例,本文代碼中含大量注釋講解了CCControlSwitch控件類的使用,需要的朋友可以參考下

CCControlSwitch是開關(guān)按鈕,關(guān)于控件使用時的一些配置,請參見文章:UI開發(fā)之控件類-CCControlButton。以下的演示中出現(xiàn)的key和value代表什么意思,知道的人說一聲。

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

    CC_BREAK_IF(! CCLayer::init());

		//參數(shù)就不說了,看一下你的資源文件就明白了
		CCControlSwitch * controlSwitch = CCControlSwitch::create(
			CCSprite::create("extensions/switch-mask.png"),
			CCSprite::create("extensions/switch-on.png"),
			CCSprite::create("extensions/switch-off.png"),
			CCSprite::create("extensions/switch-thumb.png"),
			CCLabelTTF::create("On", "Arial-BoldMT", 16),
			CCLabelTTF::create("Off", "Arial-BoldMT", 16));

		//設(shè)置位置
		controlSwitch->setPosition(ccp(240,160));

		//這個函數(shù)對應(yīng)初始時,開關(guān)的狀態(tài)是開還是關(guān)。
		controlSwitch->setOn(true);
		//這個函數(shù)對應(yīng)開關(guān)能否使用。
		controlSwitch->setEnabled(true);

		//添加事件監(jiān)聽
		controlSwitch->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::valueChanged),
			CCControlEventValueChanged);

		this->addChild(controlSwitch);

    bRet = true;
  } while (0);

  return bRet;
}

void HelloWorld::valueChanged(CCObject * pSender,CCControlEvent controlEvent)
{
	CCControlSwitch * controlSwitch = (CCControlSwitch *)pSender;
	CCLog("click");
}

相關(guān)文章

最新評論