Пример #1
0
void ItemCell::f_init(float w, float h, int type, ItemCellData* a_icd){
	removeAllChildren();

	sum = a_icd->sum;
	lock = a_icd->lock;
	initwithPre("Images/button",w,h);
	string name = a_icd->name;
	CCLOG("Ready for item:%d,%s",a_icd->type_id,name.c_str());

	m_iType = type;

	CCSprite* t_cs = CCSprite::create(CCString::createWithFormat("Images/icon_%s.png",a_icd->icon_mask.c_str())->getCString());
	t_cs->setAnchorPoint(ccp(0,0));
	t_cs->setPosition(ccp(1,1));
	addChild(t_cs);

	CCLabelTTF* t_ct = CCLabelTTF::create(name.c_str(), FNT_UI_LABEL, 20,CCSize(w,0), kCCTextAlignmentLeft);
	t_ct->setAnchorPoint(ccp(0,0));
	t_ct->setPosition(ccp(31,1));
	t_ct->setColor(COLOUR_NORMAL);
	addChild(t_ct);
	switch(type)
	{
	case(0):
		{
			labelAtlas = CCLabelBMFont::create(CCString::createWithFormat("%d",a_icd->sum)->getCString(), FNT_CHN);
			labelAtlas->setAnchorPoint(ccp(0,0));
			labelAtlas->setPosition(ccp(w-50,1));
			labelAtlas->setColor(COLOUR_NORMAL);
			addChild(labelAtlas);
			break;
		}
	case(1):
		{
			setstringnull();
			break;
		}
	case(2):
		{
			labelAtlas = CCLabelBMFont::create(CCString::createWithFormat("%d/%d",a_icd->lock,a_icd->sum)->getCString(), FNT_CHN);
			labelAtlas->setAnchorPoint(ccp(0,0));
			labelAtlas->setPosition(ccp(w-50,1));
			labelAtlas->setColor(COLOUR_NORMAL);

			addChild(labelAtlas);	
			if(a_icd->sum == a_icd->lock)			//All Equip is Equipped.
			{
				t_ct->setColor(ccGRAY);
				labelAtlas->setColor(ccGRAY);
			}
			break;
		}
	}

	//settouchstate(false);
}
Пример #2
0
void Container::initString(const char* s_Title,float width,float height,string c9img, CCObject* target, SEL_MenuHandler selector){
	//spriteNormal = new CCNode();
	//spriteSelected = new CCNode();
	//spriteHover = new CCNode();
	//addChild(spriteHover);
	//addChild(spriteNormal);
	//addChild(spriteSelected);

	initwithPre(c9img,width,height);

	labelAtlas = CCLabelBMFont::create(s_Title, "fonts/CocoTd.fnt");
	labelAtlas->setPosition(ccp(width/2,height/2));
	this->addChild(labelAtlas,1);

	m_obContentSize.width = width;
	m_obContentSize.height = height;
	m_pListener = target;
	m_pfnSelector = selector;
	m_bIsEnabled = true;
}