Esempio n. 1
0
Ref* CTableViewReloadTest::tableviewDataSource(Ref* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*) pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(Vec2(150.0f / 2, 54.0f / 2));
//		pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	pButton->getLabel()->setString(m_vDatas[idx].c_str());
	pButton->setUserTag(idx);

	return pCell;
}
Esempio n. 2
0
Ref* CTableViewBasicTest::tableviewDataSource(Ref* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*)pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(Size(70, 70), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(Vec2(74.0f / 2, 70.0f / 2));
		//pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	char buff[64];
	sprintf(buff, "%u", idx);
	pButton->getLabel()->setString(buff);
	pButton->setUserTag(idx);

	return pCell;
}
Esempio n. 3
0
CCObject* CGridViewBasicTest::gridviewDataSource(CCObject* pConvertView, unsigned int idx)
{
	CGridViewCell* pCell = (CGridViewCell*) pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CGridViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(CCPoint(480 / 5 / 2, 320 / 4 / 2));
		pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	char buff[64];
	sprintf(buff, "%u", idx);
	pButton->getLabel()->setString(buff);
	pButton->setUserTag(idx);

	return pCell;
}
Esempio n. 4
0
CCObject* CTableViewBindingDataAndVertical::tableviewDataSource(CCObject* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*)pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick));
		pButton->setPosition(CCPoint(150.0f / 2, 54.0f / 2));
		pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	pButton->getLabel()->setString(m_vDatas[idx].c_str());
	pButton->setUserTag(idx);

	return pCell;
}
Esempio n. 5
0
void CSharpTollgate::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	const vector<StageWidget> *data = DataCenter::sharedData()->getStageData()
		->getStageWidgets(m_chapter);
	CStage &stage = m_stageList.at(uIdx);

	for (int i = 0; i < 2; i++)
	{
		CCNode * node = (CCNode*)m_cell->getChildren()->objectAtIndex(i);

		if (node->getTag()==1)
		{
			const StageWidget *widget = nullptr;			
			CCString *strId = CCString::createWithFormat("hero%d",uIdx+1);
			for (int j=0; j<data->size();++j)
			{
				widget = &data->at(j);
				if (widget->widgetId!=""&&widget->widgetId.compare(strId->getCString())==0)
				{				
					CButton *btn =  CButton::create(widget->normalImage.c_str());
					btn->setScaleX(widget->scaleX);
					btn->setScaleY(widget->scaleY);
					btn->setPosition(ccp(100, 80/*btn->boundingBox().size.height*/));  
					btn->setAnchorPoint(ccp(0.5, 0.0));
					btn->setUserData(&m_stageList.at(uIdx));
					btn->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onBattle));
					btn->setTag(1);
					pCell->addChild(btn);
					if (!stage.isOpen)
					{
						btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
// 						btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
					break;
				}
			}
		}
		else if (node->getTag()==2)
		{
			CImageView *image = UICloneMgr::cloneImageView((CImageView*)node);
			if (stage.star>0)
			{		
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("tollgate/star_%d.png",stage.star)->getCString()));
			}
			else
			{
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage("tollgate/star_3.png"));
				image->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			}
			image->setAnchorPoint(ccp(0.5f,0));

			pCell->addChild(image);
		}
	}
	pCell->setVisible(false);
	pCell->setScale(1.15f);
	pCell->runAction(CCSequence::create(CCDelayTime::create(0.1f+0.15f*uIdx),CCShow::create(),CCScaleTo::create(0.05f,1.0f),CCCallFuncN::create(this,callfuncN_selector(CSharpTollgate::heroCall)),nullptr));
}
Esempio n. 6
0
CButton* TuiManager::createBtn(float tag, Color3B color, int fontSize, const char* font, const char* lab, const char* normal, const char* select, const char* disable, float x, float y, float w, float h, float rotation, int isUseFrame){
	CButton * pBtn = NULL;
	if(isUseFrame){
		pBtn = CButton::createWith9SpriteFrameName(Size(w, h), normal, select, disable);
	}else{
		pBtn = CButton::createWith9Sprite(Size(w,h),normal,select,disable);
	}
	if (lab) pBtn->initText(lab, font, fontSize, Size::ZERO, color);
	pBtn->setRotation(rotation);
	pBtn->setPosition(Vec2(x,-y));
	pBtn->setTag(tag);
	return pBtn;
}
Esempio n. 7
0
CButton* TuiManager::createBtn(float tag, const char* normal,const char* select,const char* disable,float x,float y,float w, float h,float rotation){
	CButton * pBtn = NULL;
	if(m_isUseSpriteFrame){
		pBtn = CButton::create();
		pBtn->setNormalSpriteFrameName(normal);
		pBtn->setSelectedSpriteFrameName(select);
		pBtn->setDisabledSpriteFrameName(disable);
	}else{
		pBtn = CButton::createWith9Sprite(Size(w,h),normal,select,disable);
	}
	pBtn->setRotation(rotation);
	pBtn->setPosition(Point(x,-y));
	pBtn->setTag(tag);
	return pBtn;
}
Esempio n. 8
0
CCObject* MainScene::gridviewDataSource(CCObject* pConvertView, unsigned int idx){
	CGridViewCell* pCell = (CGridViewCell*) pConvertView;
	CButton* pButton = NULL;
	CCLog("idx %d",idx);
	if(!pCell)
	{
		pCell = new CGridViewCell();
		pCell->autorelease();

		pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png");
		pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
		pButton->getLabel()->setFontSize(40.0f);
		pButton->setTag(1);

		pCell->addChild(pButton,10);

		CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png");
		sprite->setContentSize(CCSize(320,320));
		sprite->setPosition(CCPoint(360/2,350/2));
		pCell->addChild(sprite,1);
		
		CCLog("idx %d",idx);
		vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx));

		CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280),
			ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200),
			ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120),
			ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40)
		};
		for (unsigned int i = 0; i < groupCharacter.size(); i++)
		{
			string hanzi = groupCharacter.at(i).at(0);
			CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40);
			clabel->setPosition(positions[i]);
			clabel->setColor(ccc3(0,0,0));
			sprite->addChild(clabel);
		}
	}
	else
	{
		pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png");
		pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
		pButton->getLabel()->setFontSize(40.0f);
		pButton->setTag(1);

		pCell->addChild(pButton,10);

		CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png");
		sprite->setContentSize(CCSize(320,320));
		sprite->setPosition(CCPoint(360/2,350/2));
		pCell->addChild(sprite,1);

		CCLog("idx %d",idx);
		vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx));

		CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280),
			ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200),
			ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120),
			ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40)
		};
		for (unsigned int i = 0; i < groupCharacter.size(); i++)
		{
			string hanzi = groupCharacter.at(i).at(0);
			CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40);
			clabel->setPosition(positions[i]);
			clabel->setColor(ccc3(0,0,0));
			sprite->addChild(clabel);
		}
	}

	char buff[64];
	unsigned int labelidx = idx+1;
	sprintf(buff, "%u", labelidx);
	pButton->getLabel()->setString(buff);
	pButton->setUserTag(idx);

	pButton->setOnClickListener(this,ccw_click_selector(MainScene::buttonClick));
	pButton->setOnLongClickListener(this,ccw_longclick_selector(MainScene::buttonLongClick));
	return pCell;
}