当前位置: 首页>>代码示例>>C++>>正文


C++ CLabel::setPos方法代码示例

本文整理汇总了C++中CLabel::setPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CLabel::setPos方法的具体用法?C++ CLabel::setPos怎么用?C++ CLabel::setPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLabel的用法示例。


在下文中一共展示了CLabel::setPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    bool bRet = false;
    do 
    {
		
        //////////////////////////////////////////////////////////////////////////
        // super init first
        //////////////////////////////////////////////////////////////////////////
		//init GUI system
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		m_pGUI = new CGui(size.width,size.height);
		m_pGUI->setRect(CreateCRect(0,0,CLayoutParam::WRAP_CONTENT,CLayoutParam::WRAP_CONTENT));
		m_pGUI->setBkColor(CreateCColor(0,0,0,255));
		//add panel to gui
 		CPanel* pPanel = new CPanel();
 		pPanel->setBkColor(CreateCColor(0,255,0,255));
		pPanel->setRect(CreateCRect(200,200,CLayoutParam::WRAP_CONTENT,CLayoutParam::WRAP_CONTENT));
 		
 		pPanel->setZOrder(0);
 		m_pGUI->add(pPanel);
// 
// 		//add panel2 to panel1
// 		CPanel* pPanel2 = new CPanel();
// 		pPanel2->setBkColor(CreateCColor(0,0,255,128));
// 		pPanel2->setRect(CreateCRect(0,25,100,10));
// 		pPanel->add(pPanel2);
// 		//set scale to parent all child will be effected!!
// 		pPanel->setScale(2.0);
// 		//add a btn to gui
 		CCTexture2D* pPicNormal = CCTextureCache::sharedTextureCache()->addImage("CloseNormal.png");
 		CCTexture2D* pPicSel = CCTextureCache::sharedTextureCache()->addImage("CloseSelected.png");
 		CPushButton* pBtn = new CPushButton();
 		pBtn->setNormalPic(pPicNormal);
 		pBtn->setClickPic(pPicSel);
 		
 		pBtn->setRect(CreateCRect(0,0,CLayoutParam::WRAP_CONTENT,CLayoutParam::WRAP_CONTENT));
 		//pBtn->setScale(1.0f);
 		pBtn->setZOrder(1);
 		pBtn->setcmdID(HelloWorld::CMD_ID_EIXT);
		pBtn->setlongClick(true,1234567);
		pPanel->add(pBtn);
// 
// 
// 
// 		m_pGUI->add(pBtn);
// 		CCTexture2D* pPicSel = CCTextureCache::sharedTextureCache()->addImage("CloseSelected.png");
// 		CImageWidget* pImage = new CImageWidget();
// 		pImage->setPic(pPicSel);
// 		pImage->setRect(CreateCRect(0,0,CLayoutParam::WRAP_CONTENT,CLayoutParam::WRAP_CONTENT));
// 		pPanel->add(pImage);

		//for test using 
		//do not care memory link here!!!
		CActionMoveBy* pMoveBy = new CActionMoveBy();
		pMoveBy->init(2,CreateCPoint(100,100));
		

		CActionMoveTo* pMoveTo = new CActionMoveTo();
		pMoveTo->init(2,CreateCPoint(100,100));

		CActionFadeTo* pFade = new CActionFadeTo();
		pFade->init(2,0);

		CActionScaleTo* pScale = new CActionScaleTo();
		
		
		pScale->init(2,1);
		//pPanel->setScale(0);
		pPanel->runAction(pMoveTo);


		CLabel* pLabel = new CLabel();
		pLabel->setString(std::string("HelloWorld"),20,CreateCColor(255,0,0,255),std::string("宋体"));
		pLabel->setPos(100,0);
		CActionSpwan* pSpwan = new CActionSpwan();
		pSpwan->initWidthActions(pMoveBy,pFade);
		pLabel->runAction(pSpwan);
		m_pGUI->add(pLabel);

				//registe handler
		m_MyCmdHandler.addInterestCmdID(HelloWorld::CMD_ID_EIXT);
		CCommandHandlerMgr::instance()->addCmdHander(&m_MyCmdHandler);
        CC_BREAK_IF(! CCLayer::init());
		this->setTouchEnabled(true);

        bRet = true;

		GameApplication application;
		application.onCreate();
		application.didEnterApplication();


// 		CHttpRequest request1;
// 		request1.setRequestUrl("http://h.hiphotos.baidu.com/album/w%3D1366%3Bcrop%3D0%2C0%2C1366%2C768/sign=83acd2dbfaedab64747249c3c10094a0/c83d70cf3bc79f3ddf7f4820bba1cd11728b2907.jpg");
// 		request1.setSaveTargerFileAddr("download1.jpg");

// 		CLoader loader;
// 		loader.load(&request1);
//.........这里部分代码省略.........
开发者ID:tonyhu1983,项目名称:Cobra2d,代码行数:101,代码来源:HelloWorldScene.cpp


注:本文中的CLabel::setPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。