Esempio n. 1
0
bool CLabelBasicTest::onTouchEnded(Ref* pSender, Touch* pTouch, float fDuration)
{
	CLabel* pText = (CLabel*) pSender;
	pText->stopActionByTag(1);
	ScaleTo* pScaleTo = ScaleTo::create(0.1f, 1.0f);
	pScaleTo->setTag(1);
	pText->runAction(pScaleTo);
	return true;
}
Esempio n. 2
0
CWidgetTouchModel CLabelBasicTest::onTouchBegan(Ref* pSender, Touch* pTouch)
{
	CLabel* pText = (CLabel*) pSender;
	pText->stopActionByTag(1);
	ScaleTo* pScaleTo = ScaleTo::create(0.1f, 1.3f);
	pScaleTo->setTag(1);
	pText->runAction(pScaleTo);

	return eWidgetTouchTransient;
}
Esempio n. 3
0
int CSmeltArmor::updateInfoToUIAndReturnCount( CLayout* pLayout[], int iNameId[], int iValue[], const char* sRange[], int iMax, const char* sTitle )
{
	int iMaxLineCount = 0;

	for(unsigned int i=0; i<iMax; i++)
	{
		//有值
		if(iValue[i] > 0)
		{
			pLayout[iMaxLineCount]->setVisible(true);
			//设置名称
			CLabel* pInfoType = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("info_type");
			pInfoType->setString(GETLANGSTR(iNameId[i]));
			//设置值大小
			CLabel* pValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("value");
			if(atoi(pValue->getString())!=iValue[i])
			{
				pValue->setString(ToString(iValue[i]));
				pValue->runAction(CCRollLabelAction::create(0.3f, 0, iValue[i], pValue));
			}
			//目标值大小
			CLabel* pAimValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("aim_value");
			pAimValue->setString(sRange[i]);
			//存ID
			CCheckBox* pCheck = (CCheckBox*)pLayout[iMaxLineCount]->findWidgetById("check");
			pCheck->setTag(i+1);

			iMaxLineCount++;
		}

		//找到四个了,退出循环
		if(iMaxLineCount>=4)
		{
			break;
		}
	}
	//隐藏掉没有数据填充的cell
	hideNoneValueCell(iMaxLineCount, pLayout);

	//如果一个都没有,隐藏标题
	if(sTitle != nullptr)
	{
		CCNode* pNode = (CCNode*)m_ui->findWidgetById(sTitle);
		if(pNode)
		{
			pNode->setVisible(iMaxLineCount != 0);
		}
	}
	return iMaxLineCount;
}
Esempio n. 4
0
// 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);

		this->testRichTxt();
		//this->testLinearLayout();
		this->testSimpleList();
		this->scheduleUpdate();

		ZThread::Thread t(new ThreadExample());

    } while (0);
    return bRet;
}
Esempio n. 5
0
void CTopLayer::updateRoleProperty(const TMessage& tMsg)
{
	UserData *user = DataCenter::sharedData()->getUser()->getUserData();

	CCScaleTo* sc1 = CCScaleTo::create(0.15f,1.3f);
	CCScaleTo* sc2 = CCScaleTo::create(0.35f,1.0f);
	CCSequence* sqes = CCSequence::create(sc1,sc2,nullptr);

	if (user->getCoin()!=atoi(m_coinLabel->getString()))
	{
		CProgressLabel *prolab = CProgressLabel::create();
		prolab->setLabel(m_coinLabel);
		prolab->changeValueTo(user->getCoin(),0.5f);
		CCSequence* sqes1 = (CCSequence*)sqes->copy();
		m_coinLabel->runAction(sqes1);
		this->addChild(prolab);

		CLabel *label = (CLabel*)m_ui->getChildByTag(130);
		int coin = user->getCoin()-atoi(m_coinLabel->getString());
		changeLabel(label, coin);
	}
	
	if (user->getRoleGold()!=atoi(m_moneyLabel->getString()))
	{
		CProgressLabel *prolab = CProgressLabel::create();
		prolab->setLabel(m_moneyLabel);
		prolab->changeValueTo(user->getRoleGold(),0.5f);
		CCSequence* sqes1 = (CCSequence*)sqes->copy();
		m_moneyLabel->runAction(sqes1);
		this->addChild(prolab);

		CLabel *label = (CLabel*)m_ui->getChildByTag(140);
		int coin = user->getRoleGold()-atoi(m_moneyLabel->getString());
		changeLabel(label, coin);
	}
	/*
	if (user->getRoleFood()!=atoi(m_foodLabel->getString()))
	{
		CProgressLabel *prolab = CProgressLabel::create();
		prolab->setLabel(m_foodLabel);
		prolab->changeValueTo(user->getRoleFood(),0.5f);
		CCSequence* sqes1 = (CCSequence*)sqes->copy();
		m_foodLabel->runAction(sqes1);
		this->addChild(prolab);

		CLabel *label = (CLabel*)m_ui->getChildByTag(170);
		int coin = user->getRoleFood()-atoi(m_foodLabel->getString());
		changeLabel(label, coin);
	}
	*/
	if (user->getFriends()!=atoi(m_foodLabel->getString()))
	{
		CProgressLabel *prolab = CProgressLabel::create();
		prolab->setLabel(m_foodLabel);
		prolab->changeValueTo(user->getFriends(),0.5f);
		CCSequence* sqes1 = (CCSequence*)sqes->copy();
		m_foodLabel->runAction(sqes1);
		this->addChild(prolab);

		CLabel *label = (CLabel*)m_ui->getChildByTag(170);
		int coin = user->getFriends()-atoi(m_foodLabel->getString());
		changeLabel(label, coin);
	}

	CLabel *action = (CLabel*)(m_ui->findWidgetById("action"));
	if (user->getRoleAction()!=atoi(action->getString()))
	{
		CCSequence* sqes2 = (CCSequence*)sqes->copy();
		action->runAction(sqes2);
		action->setString(CCString::createWithFormat("%d/%d",user->getRoleAction(), user->getActionLimit())->getCString());
	}

}