void GameTipsSprite::setStageNum(int num){
	CCLabelAtlas* stagenumbrer =(CCLabelAtlas*) this->getChildByTag(4);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	stagenumbrer->setString(temp);
	delete temp;
}
void GameTipsSprite::setMonstTotalNum(int num){
	CCLabelAtlas* monsttotalnumbrer =(CCLabelAtlas*) this->getChildByTag(3);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	monsttotalnumbrer->setString(temp);
	delete temp;
}
Esempio n. 3
0
ItemCard* ItemCard::spriteWithFile(const char *normalImage, string id, short cardNum)
{
    ItemCard* pRet = new ItemCard(id, cardNum);
    
    if ((normalImage == NULL) || (*normalImage == 0)) {
        normalImage = "box_none.png";
    }
    
    if (pRet && pRet->initWithFile(normalImage))
    {
        pRet->autorelease();
        
        char buf[30];
        sprintf(buf, "/%d",cardNum);
        
        CCSprite* spTmp = CCSprite::spriteWithFile("rewardnum.png");
        if(spTmp){
            CCSize sz = spTmp->getContentSize();
            CCLabelAtlas* textNum = CCLabelAtlas::labelWithString(buf,
                                                                      "rewardnum.png",
                                                                      sz.width / 11,
                                                                      sz.height,
                                                                      '/');
            textNum->setAnchorPoint(ccp(0.5, 0.5));
            textNum->setPosition(ccp(54,10));
            pRet->addChild(textNum,0,9);
        }
        
        return pRet;
    }
    
    CC_SAFE_DELETE(pRet);
    return NULL;
}
Esempio n. 4
0
CCSprite* LevelScene::addMapBtnWith(int no, cocos2d::CCPoint pos, CCSpriteBatchNode* batch)
{
    CCSprite *map = NULL;
    CCSprite *lockSprite = NULL;
    CCLabelAtlas *mapNo = CCLabelAtlas::create("0123456789", "fonts_score_002-hd.png", 38, 44, '0');

    if (FruitCrush::shareSingleton()->canPlayMap(no)) {
        map = CCSprite::createWithTexture(batch->getTexture());
        map->setTag(no);
        //map->setScale(0.6);
        CCString* num = CCString::createWithFormat("%u", no);
        mapNo->setString(num->getCString());
        //mapNo->setColor(ccc3(242, 247, 240));
        mapNo->setAnchorPoint(ccp(0.5f,0.5f));
        mapNo->setPosition(ccp(map->boundingBox().size.width/2, map->boundingBox().size.height/2));
        map->addChild(mapNo);
        //this->addChild(mapNo);
    }
    else
    {
        
    }
    
    map->setPosition(pos);
    map->setScale(0.8);
    this->addChild(map);
    return map;
    
}
Esempio n. 5
0
void SecondLevel::tenSecondsCallback(float dt)
{
	time -= dt;
	if (time < 1)
	{
		CCDictionary *dict = CCDictionary::createWithContentsOfFile("/word/words.xml");
		const char *lose_word = ((CCString*)dict->objectForKey("lose"))->m_sString.c_str();
		CCLabelTTF *lose = CCLabelTTF::create(lose_word, "Arial", 24);
		lose->setColor(ccc3(255, 0, 0));
		lose->setPosition(ccp(150, 150));
		result->addChild(lose);

		int score = userDefault->getIntegerForKey("score");

		stringstream ss;
		ss << (score);
		CCLabelAtlas *lable = CCLabelAtlas::create(ss.str().c_str(), "/pic/numbers.png", 23, 26, '0');
		lable->setPosition(ccp(150, 100));
		result->addChild(lable);

		result->setVisible(true);
		this->unschedule(schedule_selector(SecondLevel::tenSecondsCallback));
	}
	char time_str[20];
	sprintf(time_str, "%d", (int)time);
	CCLabelBMFont *label1 = (CCLabelBMFont *)this->getChildByTag(15);
	label1->setString(time_str);
}
Esempio n. 6
0
Letter::Letter(char letter, size_t id): letter(toupper(letter)), id(id){
	// TODO - нужно либо делать rect метод чтобы правильный размер сделать
	// либо он на автомате будет работать. я не знаю
	CCSprite::init();
	//this->setTouchEnabled(true);
	this->autorelease();

	// TODO 1 раз получать - для всех использовать потом
	letterImage = CCSprite::create("letter32_2.png");
	letterImage->setScale(32 / letterImage->getContentSize().width);
	char arr[2] = {this->letter, '\0'};


	//CCLabelTTF *letterLabel = CCLabelTTF::create(arr, "fonts/Schwarzwald Regular.ttf", 22);
	//CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize,
	//                                      blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]);

	//CCLabelTTF *letterLabel = CCLabelTTF::create(arr, /*"fonts\sylfaen.ttf"*/"Sylfaen", 50);


	//CCLabelBMFont *letterLabel = CCLabelBMFont::create(arr, "fonts/hd/markerFelt.fnt", 10);
	//letterLabel->setScale(0.5);

	CCLabelAtlas *letterLabel = CCLabelAtlas::create(arr, "fonts/hd/larabie-16.plist");
	letterLabel->setAnchorPoint(ccp(0.5f, 0.5f));
	letterLabel->setColor(ccc3(85,47,17));
	//letterLabel->setColor(ccc3(0,0,0));

	this->addChild(letterImage,1);
	this->addChild(letterLabel,2);
}
Esempio n. 7
0
void MarketScene::updateLabelAtlas(int num, int tag)
{
	char txt[32] = { 0 };
	sprintf(txt, "%d", num);
	CCLabelAtlas *label = (CCLabelAtlas *)getChildByTag(tag);
	label->setString(txt);
}
CCLabelAtlas* DamageValueEffect::CreateAddBloodLabel(unsigned int blood,CCPoint parentPos)
{
	CCPoint uiPos = parentPos;
	char damageString[10];
	sprintf(damageString,"%d",blood);
	CCLabelAtlas* lable = CCLabelAtlas::create(damageString,"UI/ui_numble_4.png",41,43,48);

	lable->setPosition(uiPos.x,uiPos.y);
	lable->setAnchorPoint(ccp(0.5,0.5));
	lable->setScale(0);
	CCActionInterval* actionScale = CCScaleTo::create(0.01f,2);
	CCActionInterval* actionMove = CCMoveBy::create(0.01f,ccp(0,40));
	CCSpawn* FirstAction = CCSpawn::createWithTwoActions(actionScale,actionMove);
	CCActionInterval* actionFade = CCFadeOut::create(1.0f);
	CCActionInterval* bezierAction = CCMoveBy::create(1.0f,ccp(0,80));
	CCSpawn* SecondAction = CCSpawn::createWithTwoActions(bezierAction,actionFade);
	lable->runAction(CCSequence::create(FirstAction,CCScaleTo::create(0.05f,0.7f),CCDelayTime::create(0.2f),SecondAction,
		NULL));
	if(m_pDamageLabels->find(lable) == m_pDamageLabels->end())
	{
		m_pDamageLabels->insert(make_pair(lable,1.3f));
		if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL
			&& GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer())
		{
			GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(lable,MAP_Z_OBJ_TOP);
		}
	}
	return lable;
}
Esempio n. 9
0
void RatingSprite::setLeverNum(int num){
    CCLabelAtlas* numbrer =(CCLabelAtlas*) this->getChildByTag(2);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	numbrer->setString(temp);
	delete temp;
}
Esempio n. 10
0
void ParticleMainScene::step(float dt)
{
    CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas);
    CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem);

    char str[10] = {0};
    sprintf(str, "%4d", emitter->getParticleCount());
    atlas->setString(str);
}
Esempio n. 11
0
void IOSStoreLayer::setStarCount(int num)
{
	CCLabelAtlas* pTipStr = (CCLabelAtlas*)m_pBg->getChildByTag(star_count_str_tag);
	if (pTipStr)
	{
		pTipStr->setString(CCString::createWithFormat("%d", num)->getCString());
	}
	this->setKaiBaoxiangBtnVisiable();
}
ParticleDemo::ParticleDemo(void)
{
	initWithColor( ccc4(127,127,127,255) );

	m_emitter = NULL;

	setIsTouchEnabled( true );
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
	addChild(label, 100, 1000);
	label->setPosition( CCPointMake(s.width/2, s.height-50) );
	
	CCLabelTTF *tapScreen = CCLabelTTF::labelWithString("(Tap the Screen)", "Arial", 20);
	tapScreen->setPosition( CCPointMake(s.width/2, s.height-80) );
	addChild(tapScreen, 100);
	
	CCMenuItemImage* item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) );
	CCMenuItemImage* item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) );
	CCMenuItemImage* item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2,  this, menu_selector(ParticleDemo::nextCallback) );
	
	CCMenuItemToggle* item4 = CCMenuItemToggle::itemWithTarget(	this, 
																menu_selector(ParticleDemo::toggleCallback), 
																CCMenuItemFont::itemFromString( "Free Movement" ),
                                                                CCMenuItemFont::itemFromString( "Relative Movement" ),
																CCMenuItemFont::itemFromString( "Grouped Movement" ),
																NULL );
	
	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, NULL);
		
	menu->setPosition( CCPointZero );
	item1->setPosition( CCPointMake( s.width/2 - 100,30) );
	item2->setPosition( CCPointMake( s.width/2, 30) );
	item3->setPosition( CCPointMake( s.width/2 + 100,30) );
	item4->setPosition( CCPointMake( 0, 100) );
	item4->setAnchorPoint( CCPointMake(0,0) );

	addChild( menu, 100 );	
	
    CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.');
    addChild(labelAtlas, 100, kTagLabelAtlas);
	labelAtlas->setPosition( CCPointMake(s.width-66,50) );
	
	// moving background
	m_background = CCSprite::spriteWithFile(s_back3);
	addChild(m_background, 5);
	m_background->setPosition( CCPointMake(s.width/2, s.height-180) );

	CCActionInterval* move = CCMoveBy::actionWithDuration(4, CCPointMake(300,0) );
	CCActionInterval* move_back = move->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL);
	m_background->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq) );
	
	
	schedule( schedule_selector(ParticleDemo::step) );
}
Esempio n. 13
0
void CWaterpump::ResetAxeNum(cocos2d::CCMenuItemSprite *pItem, int num)
{
    CCLabelAtlas *pItemFnt = dynamic_cast<CCLabelAtlas*>(pItem->getChildByTag(Tag_ItemFnt));
    if (NULL != pItemFnt)
    {
        char szNum[8] = {0};
        sprintf(szNum, "%d", num);
        pItemFnt->setString(szNum);
    }
}
Esempio n. 14
0
void ParticleDemo::step(ccTime dt)
{
    if (m_emitter)
    {
	    CCLabelAtlas* atlas = (CCLabelAtlas*)getChildByTag(kTagLabelAtlas);
        char str[5] = {0};
        sprintf(str, "%04d", m_emitter->getParticleCount());
	    atlas->setString(str);
    }
}
Esempio n. 15
0
//CCLabelAtlas - Creation & Init
CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, StreamSource* charMapSource, unsigned int itemWidth, int unsigned itemHeight, unsigned char startCharMap)
{
	CCLabelAtlas *pRet = new CCLabelAtlas();
	if(pRet && pRet->initWithString(label, charMapSource, itemWidth, itemHeight, startCharMap))
	{
		pRet->autorelease();
		return pRet;
	}
	CC_SAFE_DELETE(pRet)
	return NULL;
}
Esempio n. 16
0
void LayerGoods::menuCallbackBuy(CCObject* pSender)
{
	if (pSender)
	{
		Topwo::getInstance()->getTopwoAudio()->playEffect(1);
	}

	if (!pSender)
	{
		return;
	}
	TopwoTools *tl = Topwo::getInstance()->getTopwoTools();
	UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();

	CCMenuItemSprite* item = static_cast<CCMenuItemSprite*>(pSender);
	int tag = item->getTag();
	CCSprite* sprite = static_cast<CCSprite*>(this->getChildByTag(tag));
	CCLabelAtlas* la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
	int need_gold = atoi(la->getString());
	int cur_gold = user_info->getCurrentGold();
	if (need_gold > cur_gold)
	{//金币不足
		this->addChild(LayerHint::createWith(CCLabelTTF::create(CCString::createWithFormat("%s%s", tl->getXmlString("Gold")->getCString(), tl->getXmlString("HintNotEnough")->getCString())->getCString(), "", 30), 2, this, callfuncN_selector(LayerGoods::hintCallbackWork)), 10);
		return;
	}
	user_info->setCurrentGold(cur_gold - need_gold);
	if (tag == 1)
	{
		user_info->setCurrentGoodsLevelTiPo(user_info->getCurrentGoodsLevelTiPo() + 1);
		user_info->setCurrentTiPoBonus(getGoodsBonus(user_info->getCurrentGoodsLevelTiPo()) * 0.01f);
	}
	else if (tag == 2)
	{
		user_info->setCurrentGoodsLevelMeiLi(user_info->getCurrentGoodsLevelMeiLi() + 1);
		user_info->setCurrentMeiLiBonus(getGoodsBonus(user_info->getCurrentGoodsLevelMeiLi()) * 0.01f);
	}
	else if (tag == 3)
	{
		user_info->setCurrentGoodsLevelZhiLi(user_info->getCurrentGoodsLevelZhiLi() + 1);
		user_info->setCurrentZhiLiBonus(getGoodsBonus(user_info->getCurrentGoodsLevelZhiLi()) * 0.01f);
	}
	else if (tag == 4)
	{
		user_info->setCurrentGoodsLevelEQ(user_info->getCurrentGoodsLevelEQ() + 1);
		user_info->setCurrentEQBonus(getGoodsBonus(user_info->getCurrentGoodsLevelEQ()) * 0.01f);
	}
	else if (tag == 5)
	{
		user_info->setCurrentGoodsLevelGanXing(user_info->getCurrentGoodsLevelGanXing() + 1);
		user_info->setCurrentGanXingBonus(getGoodsBonus(user_info->getCurrentGoodsLevelGanXing()) * 0.01f);
	}

	updateMe();
}
Esempio n. 17
0
CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap)
{
    CCLabelAtlas *pRet = new CCLabelAtlas();
    if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
Esempio n. 18
0
//******************************************************************************
// useAutoSkill
//******************************************************************************
void Card::useAutoSkill(float fEffect, int iBaoJi)
{
    float fDur = 0.0;
    
    if(fEffect < -2.0){
        fDur = 0.3;
    }
    else if(fEffect < 0.0){
        fDur = 0.1;
    }
    else{
        m_AtkInfo.iAttackPt *= fEffect;
        m_numAtkVal->setNumber(m_AtkInfo.iAttackPt, 0.6, 0.0);
        
        fDur = 0.3;
    }
    
    CCPoint ptSrc = CCPointMake(0, 0);
    if (getCD() == 0)
        ptSrc = CCPointMake(0, 8);
    CCPoint ptDst = CCPointMake(ptSrc.x, ptSrc.y + 8);
    
    this->stopAllActions();
    this->setPositionInPixels(ptSrc);
    this->runAction(CCSequence::actions(CCMoveTo::actionWithDuration(fDur, ptDst),
                                        CCMoveTo::actionWithDuration(fDur, ptSrc),
                                        NULL));
    
    if (iBaoJi > 0) {
        CCSprite* spBaojiBg = CCSprite::spriteWithSpriteFrameName("baojibg.png");
        if (spBaojiBg) {
            spBaojiBg->setAnchorPoint(CCPointMake(0.5, 0));
            spBaojiBg->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            addChild(spBaojiBg,0,kToBeDeleteTag);
        }
        
        CCSprite *sp = CCSprite::spriteWithFile("baojinum.png");
        if (sp) {
            char buf[10];
            snprintf(buf, 9, "/%d", iBaoJi);
            CCLabelAtlas *lbb = CCLabelAtlas::labelWithString(buf,
                                                              "baojinum.png",
                                                              sp->getContentSize().width / 11,
                                                              sp->getContentSize().height, '/');
            lbb->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            lbb->setAnchorPoint(CCPointMake(0.5, 0));
            addChild(lbb,0,kToBeDeleteTag);
            
            lbb->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(fDur*2),
                                               CCCallFunc::actionWithTarget(this, callfunc_selector(Card::delUnusedObj)),
                                               NULL));
        }
    }
}
Esempio n. 19
0
void MarketScene::initLabelAtlas()
{
	CCSprite *sprite = CCSprite::create(s_pathMarketTomato.m_strPath);
	sprite->setPosition(s_pathMarketTomato.m_Position);
	addChild(sprite);

	CCLabelAtlas *pTextLabel = g_Control.creatLabelAtlas(g_Control.m_nCoin, s_pNumMarketCoin, this, LabelAtlas_COIN);
	pTextLabel->setPosition(s_pNumMarketCoin.m_Position);

	pTextLabel = g_Control.creatLabelAtlas(PRICE_CHANGE_QUESTION, s_pNumMarketCoin, this, LabelAtlas_PRICE);
	pTextLabel->setPosition(ccp(s_pNumMarketCoin.m_Position.x, s_pNumMarketCoin.m_Position.y - 260));
}
Esempio n. 20
0
	bool CCMenuItemAtlasFont::initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MenuHandler selector)
	{
		NSAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
		CCLabelAtlas *label = new CCLabelAtlas();
		label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
		label->autorelease();
		if (CCMenuItemLabel::initWithLabel(label, target, selector))
		{
			// do something ?
		}
		return true;
	}
Esempio n. 21
0
void SelectLevel::displayScore()
{
	stringstream ss;
	ss << (score);
	CCLabelAtlas *lable = CCLabelAtlas::create(ss.str().c_str(), "/pic/numbers.png", 23, 26, '0');

	CCLabelTTF *s_score = CCLabelTTF::create("SCORE:", "Arial", 34);
	s_score->setPosition(ccp(winSize.width / 2 - 80, 44));
	s_score->setColor(ccc3(255, 0, 0));
	lable->setPosition(ccp(winSize.width / 2, 30));

	this->addChild(s_score, 1);
	this->addChild(lable, 1);
}
Esempio n. 22
0
NS_CC_BEGIN

//CCLabelAtlas - Creation & Init
CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned char startCharMap)
{
    CCLabelAtlas *pRet = new CCLabelAtlas();
    if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
Esempio n. 23
0
void LayerGoods::updateMe()
{
	UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();

	CCMenu* menu = static_cast<CCMenu*>(this->getChildByTag(0));
	//体魄
	int goods_level = 0;
	CCMenuItemSprite* item = NULL;
	CCSprite* sprite = NULL;
	CCLabelAtlas* la = NULL;
	for (int i = 1; i <= 5; i++)
	{
		if (i == 1)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelTiPo());
		}
		else if (i == 2)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelMeiLi());
		}
		else if (i == 3)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelZhiLi());
		}
		else if (i == 4)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelEQ());
		}
		else if (i == 5)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelGanXing());
		}
		item = static_cast<CCMenuItemSprite*>(menu->getChildByTag(i));
		if (goods_level >= 9)
		{
			item->setEnabled(false);
			item->setColor(ccc3(128, 128, 128));
		}
		sprite = static_cast<CCSprite*>(this->getChildByTag(i));
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(0));
		la->setString(CCString::createWithFormat("%d", goods_level)->getCString());
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(1));
		la->setString(CCString::createWithFormat("%d", getGoodsBonus(goods_level))->getCString());
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
		la->setString(CCString::createWithFormat("%d", getGoodsPrice(goods_level))->getCString());
	}

	SceneMain* scene_main = static_cast<SceneMain*>(CCDirector::sharedDirector()->getRunningScene()->getChildByTag(0));
	scene_main->updateMe();
}
Esempio n. 24
0
void ScoreCenter::showPromptScore(int score, CCPoint ppoint)
{
    CCString* curScore = CCString::createWithFormat("%u", score);
    CCLabelAtlas* label = ResCenter::shareInstance()->getLableAtlasByType(ResCenter::klableScore);
    label->setPosition(ppoint);
    //label->setScale(0.5);
    label->setString(curScore->getCString());
    
    CCFiniteTimeAction* sf = ActionEffectHub::shareInstance()->scoreFly();
    CCFiniteTimeAction* cb = CCCallFuncN::create(this, callfuncN_selector(ScoreCenter::_removeScorePrompt));

    CCSequence* cbSeq = CCSequence::create(sf, cb, NULL);
    label->runAction(cbSeq);
    this->getLayer()->addChild(label);
}
Esempio n. 25
0
CCLabelAtlas* ResCenter::getLableAtlasByType(ResCenter::typeLableAtlas type)
{
    switch (type) {
        case klableScore:
        {
            CCLabelAtlas* lable = CCLabelAtlas::create("0123456789", "fonts_roulette_001-hd.png", 24, 32, '0');
            lable->setAnchorPoint(ccp(0.5, 0.5));
            return lable;
            break;
        }
            
            
        default:
            break;
    }
}
Esempio n. 26
0
void GameScene::showGameOver() {
    CCSprite* over = CCSprite::createWithSpriteFrameName("gameOver.png");
    over->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.7f));
    over->setScale(1.5f);
    addChild(over, 10);
    
    CCSprite* scoreBoard = CCSprite::createWithSpriteFrameName("score_board.png");
    scoreBoard->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    scoreBoard->setScale(1.5f);
    addChild(scoreBoard, 10);
    
    CCLabelAtlas* curScore = CCLabelAtlas::create(CCString::createWithFormat("%d", gameScore)->getCString(), "score_number.png", 30, 45, '0');
    curScore->setAnchorPoint(ccp(1, 0.5f));
    curScore->setScale(0.75f);
    curScore->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.53f));
    addChild(curScore, 10);
    
    int maxScore = CCUserDefault::sharedUserDefault()->getIntegerForKey("MAX", 0);
    if (gameScore > maxScore) {
        maxScore = gameScore;
        CCUserDefault::sharedUserDefault()->setIntegerForKey("MAX", gameScore);
        CCUserDefault::sharedUserDefault()->flush();
        CCSprite* showNew = CCSprite::createWithSpriteFrameName("new.png");
        showNew->setAnchorPoint(ccp(0, 0.5f));
        showNew->setScale(1.5f);
        showNew->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.45f));
        addChild(showNew, 10);
    }
    
    CCLabelAtlas* highScore = CCLabelAtlas::create(CCString::createWithFormat("%d", maxScore)->getCString(), "score_number.png", 30, 45, '0');
    highScore->setAnchorPoint(ccp(1, 0.5f));
    highScore->setScale(0.75f);
    highScore->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.45f));
    addChild(highScore, 10);
    
    removeChildByTag(999);
    
    CCMenuItemSprite* item = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("start.png"), CCSprite::createWithSpriteFrameName("start.png"), this, menu_selector(GameScene::restart));
    item->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
    CCMenu* menu = CCMenu::create(item, NULL);
    menu->setPosition(CCPointZero);
    addChild(menu, 10);
    
    if (gameScore >= 10) {
        CCSprite* metalName = NULL;
        if (gameScore >= 10 && gameScore < 50) {
            metalName = CCSprite::createWithSpriteFrameName("medals_1.png");
        } else if (gameScore >= 50 && gameScore < 100) {
            metalName = CCSprite::createWithSpriteFrameName("medals_2.png");
        } else if (gameScore >= 100) {
            metalName = CCSprite::createWithSpriteFrameName("medals_3.png");
        }
        metalName->setScale(1.5f);
        metalName->setPosition(ccp(screenSize.width * 0.3f, screenSize.height * 0.495f));
        addChild(metalName, 10);
    }
}
Esempio n. 27
0
CCMenuItemSprite *CWaterpump::initMenuItemWithFiles(int type, const char *normal, const char *selected, const char *disable, SEL_MenuHandler selector)
{
    CCSprite *pNormal = CCSprite::create(normal);
    CCSprite *pSelected = CCSprite::create(selected);
    CCSprite *pDisable = CCSprite::create(disable);

    CCMenuItemSprite *pItem = CCMenuItemSprite::create(pNormal, pSelected, pDisable, this, selector);
    int cnt = CPlayerAccount::GetAccountInstance()->GetAccountPropsNum(type);
    char szCntStr[8] = {0};
    sprintf(szCntStr, "%d", cnt);
    CCLabelAtlas *pCntFnt = CCLabelAtlas::create(szCntStr, "UI_02_05.png", 48, 57, '0');
    pCntFnt->setAnchorPoint(ccp(1, 0));
    pCntFnt->setPosition(ccp(pItem->getContentSize().width, 0));
    pItem->addChild(pCntFnt, 1, Tag_ItemFnt);
    pItem->setTag(type);
    return pItem;
}
Esempio n. 28
0
CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile)
{    
    CCLabelAtlas *ret = new CCLabelAtlas();
    if (ret)
    {
        if (ret->initWithString(string, fntFile))
        {
            ret->autorelease();
        }
        else 
        {
            CC_SAFE_RELEASE_NULL(ret);
        }
    }
    
    return ret;
}
Esempio n. 29
0
NS_CC_BEGIN

//CCLabelAtlas - Creation & Init

CCLabelAtlas * CCLabelAtlas::create(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap, float space)
{
    CCLabelAtlas *pRet = new CCLabelAtlas();
    if(pRet)
    {
        pRet->m_space = space;
        pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap);
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
Esempio n. 30
0
void RpgPlayer::beAttacked(int atkValue)
{
	if (hp <= 0)
	{
		return;
	}
	int oldhp = hp;
	if (hp >= atkValue)
	{
		hp -= atkValue;
	}
	else
	{
		hp = 0;
	}
	
	atkValue = oldhp-hp;
	if (atkValue)
	{
		std::stringstream ss;
		ss << atkValue;
		//CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"fps_images.png", 12, 32, '.');
		CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"numbers_1.png", 41.28, 81, '.');
		labelAtlas->setVisible(true);
		//labelAtlas->setPosition(ccp(125,125));
		labelAtlas->setColor(ccc3(255,0,0));
		CCAction *spawn = CCSpawn::create(CCMoveBy::create(0.5f,ccp(0,64)),CCFadeOut::create(0.5),NULL);
		labelAtlas->runAction(spawn);
		this->addChild(labelAtlas,2);
		CCSprite::runAction(CCSequence::create(CCDelayTime::create(0.6),
			CCCallFuncND::create(this, callfuncND_selector(RpgMonster::actionEnd_removeLabel), (void*)labelAtlas),NULL));
		showHp();
		tryConbineAction(RpgMonster::ACTION_BE_ATTACK);
	}
	if (ui)
	{
		ui->updateHp(this);
	}
	if (hp <=0)
	{
		doDeath(); // RpgMonster 将死亡
	}
}