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);
    }
}
示例#2
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));
}
示例#3
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);
}
示例#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;
    
}
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;
}
示例#6
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;
}
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) );
}
示例#8
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);
}
示例#9
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);
}
示例#10
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;
}
示例#11
0
bool GameScene::ccTouchBegan(CCTouch* pTouch, CCEvent* pEvent) {
    if (isGameOver) {
        return true;
    }
    
    if (isShowingHint) {
        removeChildByTag(TAG_HINT, true);
        isShowingHint = false;
        
        CCSprite* bird = (CCSprite*)getChildByTag(TAG_BIRD);
        if (bird) {
            bird->stopAllActions();
            
            CCAnimation* animation = CCAnimation::create();
            for (int i = 0; i < 3; i++) {
                CCString* birdName = CCString::createWithFormat("bird%d_%d.png", birdID, i);
                CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(birdName->getCString());
                animation->addSpriteFrame(frame);
            }
            animation->setDelayPerUnit(0.08f);
            CCAnimate* animate = CCAnimate::create(animation);
            CCRepeatForever* repeat = CCRepeatForever::create(animate);
            bird->runAction(repeat);
        }
        CCLabelAtlas* score = CCLabelAtlas::create("0", "score_number.png", 30, 45, '0');
        score->setAnchorPoint(ccp(0.5f, 0.5f));
        score->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.85f));
        score->setScale(1.5f);
        addChild(score, 10, 999);
        
        schedule(schedule_selector(GameScene::pipeCreate), 1.5f, 99999, 2.0f);
        scheduleUpdate();
    }
    
    birdFlyLogic();
    
    return true;
}
示例#12
0
void SelectLevel::displayLevels()
{
	stringstream ss;
	CCLabelAtlas *lable = NULL;
	MyButton *but = NULL;
	string str_level, str_description;
	CCScene *scene = NULL;

	int max_level = userDefault->getIntegerForKey("max_level");
	float xPosition = CONSTANT->getFirstLevelPosition()[0];
	float yPosition = CONSTANT->getFirstLevelPosition()[1];
	CCDictionary *dict = CCDictionary::createWithContentsOfFile("/word/words.xml");
	
	for (int i = 0; i < max_level; i++)
	{
		ss << (i + 1);
		lable = CCLabelAtlas::create(ss.str().c_str(), "/pic/numbers.png", 23, 26, '0');

		but = MyButton::createWithTexture(IMAGEPOOL->textureForKey("/pic/level.png"));
		but->setTag(0);
		
		scene = CONSTANT->getAllLevels()[i];
		but->setNavigation(scene);

		but->addChild(lable);
		lable->setPosition(ccp(25, 25));

		but->setPosition(ccp(xPosition + i % 4 * 84, yPosition - i / 4 * 83));
		this->addChild(but, 1);

		ss.str("");

	}

	Constant::isSetLevel = false;

}
示例#13
0
////////////////////////////////////////////////////////////////////////////////
/// \brief      Rangking 값을 읽어와 표시
////////////////////////////////////////////////////////////////////////////////
void JS_Result::displayRanking(float dt)
{
	// CCUserDefault 에서 key값으로 랭킹값을 읽어서 순위를 표시한다.
	SANG_GAME_RANK rank[JS_MAX_RANK];

	SANG_RANK_KEY key[JS_MAX_RANK];
	
	for ( int k = 0; k < JS_MAX_RANK; k++ )
	{
		if ( EASY == m_nGameLevel )
		{
			sprintf(key[k].rank_key, "js_easy_rank%d", k+1);
			sprintf(key[k].time_key, "js_easy_time%d", k+1);
			sprintf(key[k].date_key, "js_easy_date%d", k+1);
		}
		else
		{
			sprintf(key[k].rank_key, "js_hard_rank%d", k+1);
			sprintf(key[k].time_key, "js_hard_time%d", k+1);
			sprintf(key[k].date_key, "js_hard_date%d", k+1);
		}
	}

	int nTime = 0;
	std::string strZero = "0";
	// Get Rank data
	for ( int r = 0; r < JS_MAX_RANK; r++ )
	{
		sprintf(rank[r].rank, "%d", r+1);
		nTime = CCUserDefault::sharedUserDefault()->getIntegerForKey(key[r].time_key);
		sprintf(rank[r].time, "%d", nTime);
		sprintf(rank[r].date, "%d", nTime);//CCUserDefault::sharedUserDefault()->getStringForKey(key[r].date_key, strZero.c_str()).c_str());
	}

	int nTemp = 0;
	for ( int i = 0; i < JS_MAX_RANK; i++ )
	{
		nTemp = atof(rank[i].time);
		if ( nTemp != 0 && nTemp >= m_nPlayTime || nTemp == 0)
		{
			//int nRet = 0;
			if (nTemp != 0 && nTemp != m_nPlayTime)
			{
				for ( int k = JS_MAX_RANK-1; k > i; k-- )
				{
					sprintf(rank[k].date, "%s", rank[k-1].date);
					sprintf(rank[k].time, "%s", rank[k-1].time);
				}
			}

			time_t t = time(0);
			struct tm *aTime = localtime(&t);

			// Month is 0 - 11, add 1 to get a jan-dec 1-12 concept
			// Year is # years since 1900
			sprintf(rank[i].date, "%04d-%02d-%02d", aTime->tm_year + 1900, aTime->tm_mon + 1 , aTime->tm_mday);
			sprintf(rank[i].time, "%d", m_nPlayTime);
			m_nRank = i + 1;

			// Update Rank Data
			for ( int u = 0; u < JS_MAX_RANK; u++ )
			{
				CCUserDefault::sharedUserDefault()->setIntegerForKey(key[u].rank_key, u+1);
				CCUserDefault::sharedUserDefault()->setStringForKey(key[u].time_key, rank[u].time);
				CCUserDefault::sharedUserDefault()->setStringForKey(key[u].date_key, rank[u].date);
			}
			CCUserDefault::sharedUserDefault()->flush();
			break;
		}
		m_nRank = -1;	// 순위 밖
	}
	
	char cRankData[100];
	for ( int i = 0; i < JS_MAX_RANK; i++ )
	{
		// 랭킹 데이터 출력
		CCLabelAtlas *pRankLabel = new CCLabelAtlas();
		if ( atof(rank[i].rank) < 10 && atof(rank[i].time) < 10 )
			sprintf(cRankData,"%s		       %s		     %s",rank[i].rank, rank[i].time, rank[i].date);
		else if ( atof(rank[i].rank) < 10 && atof(rank[i].time) >= 10 )
			sprintf(cRankData,"%s		       %s		    %s",rank[i].rank, rank[i].time, rank[i].date);
		else if ( atof(rank[i].rank) >= 10 && atof(rank[i].time) < 10 )
			sprintf(cRankData,"%s		      %s		     %s",rank[i].rank, rank[i].time, rank[i].date);
		else
			sprintf(cRankData,"%s		      %s		    %s",rank[i].rank, rank[i].time, rank[i].date);

		if ( m_nRank == i + 1 )
			pRankLabel->initWithString(cRankData, "common/game/num_font_red.png", 24, 32, '0');
		else
			pRankLabel->initWithString(cRankData, "common/game/num_font_white.png", 24, 32, '0');

		CCPoint ptRankData;
		ptRankData.x = RANK_X;
		ptRankData.y = RANK_Y - (pRankLabel->getContentSize().height * i);
		pRankLabel->setPosition(ptRankData);

		this->addChild(pRankLabel, 400+i);
	}
}
void SectionItem::initButton(SectionItem* button,bool canChoose)
{
	button->canChoose = canChoose;
	ResManager* resMgr = ResManager::getManager();
	
	if (!canChoose)
	{
		initWithFile(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_lock_bg.png").c_str());
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data))
		{
			CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
			addChild(img);
			img->setPosition(ccp(getContentSize().width-7, getContentSize().height));
		}
*/
	}else
	{
		char fileName[128];
		sprintf(fileName, (resMgr->getSharedFilePath()+g_seasonlayerPath+"sectionItem_%d_bg.png").c_str(),button->currentScore);
		initWithFile(fileName);
		if (button->currentScore == 0)
		{
			CCSprite *ef = CCSprite::create(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_new_bg.png").c_str());
			addChild(ef);
			ef->setPosition(ccp(ef->getContentSize().width/2, ef->getContentSize().height/2 - 3));
			ef->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.5f), CCFadeIn::create(1.5f), NULL)));
		}
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state != DJS_NotGetted)
		{
			CCSprite *img = CCSprite::create(resMgr->getSharedFilePath(g_daojuPath+data.fileName).c_str());
			addChild(img);
			img->setPosition(ccp(getContentSize().width/2, 120));
			img->setScale(0.75f);
		}
		*/
		if (false)
		{
		}
		else 
		{
	
			CCLabelAtlas* lable = CCLabelAtlas::create(
				"0123456789",
				resMgr->getSharedFilePath(g_seasonlayerPath+"season_section_num.png").c_str(),
				40, 49,//24
				'0');
			addChild(lable);
			char id[5];
			sprintf(id,"%d",button->sectionId);
			lable->setString(id);
			lable->setPosition(ccp(getContentSize().width/2 - lable->getContentSize().width/2,90));
			
			//屏蔽剧情道具相关
/*			if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state == DJS_NotGetted)
			{
				CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
				addChild(img);
				img->setPosition(ccp(getContentSize().width-5, getContentSize().height+10));

				CCAnimation *animation = CCAnimation::create();
				for (int idx=1; idx<=16; ++idx){
					animation->addSpriteFrameWithFileName(CCString::createWithFormat("sectionItem_daoju_weihuode_%d.png", idx)->getCString());
				}
				animation->setDelayPerUnit(0.02f);
				img->runAction(CCRepeatForever::create(CCSequence::create(CCAnimate::create(animation), CCDelayTime::create(1), NULL)));
			}
*/
		}
	}
}
示例#15
0
bool ResulitLayer::initResulitLayer()
{
	CCLayer::setIsKeypadEnabled(true);
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	this->setContentSize(winSize);
	std::string strName = "";
	strName = s_language + "tongji.png";
	CCSprite *bg = CCSprite::spriteWithFile(strName.c_str());
	bg->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	addChild(bg);
	float bgheight = bg->getContentSize().height;
	//grade 
	std::string StrOne = "";
	StrOne = s_language + "score.png";
	CCSprite *nowGrade = CCSprite::spriteWithFile(StrOne.c_str());
	nowGrade->setPosition(ccp(50, bgheight - 180));
	nowGrade->setAnchorPoint(ccp(0, 0));
	bg->addChild(nowGrade);

	stringstream ss;
	ss << PlayerMrg::getInstance()->getPlayer()->getPlayerGrade();
	CCLabelAtlas* gradeLabel = CCLabelAtlas::labelWithString(ss.str().c_str(), "grade.png", 32, 45, '/');//CCLabelTTF::labelWithString(ss.str().c_str(), "Arial", 30);
	gradeLabel->setAnchorPoint(ccp(0, 0));
	gradeLabel->setPosition(ccp(50 + nowGrade->getContentSize().width + 5, bgheight - 180));
	gradeLabel->setScale(0.75);
	bg->addChild(gradeLabel); 
    //lastHightGrade 
	std::string stdName = "";
	stdName = s_language + "topscore.png";
	CCSprite *lastGrade = CCSprite::spriteWithFile(stdName.c_str());
	lastGrade->setPosition(ccp(50, bgheight - 220));
	lastGrade->setAnchorPoint(ccp(0, 0.5));
	bg->addChild(lastGrade);

	ss.str("");
	ss.clear();
	ss << PlayerMrg::getInstance()->getPlayerLastHightGrade();
	CCLabelAtlas* lastgradeLabel = CCLabelAtlas::labelWithString(ss.str().c_str(), "grade.png", 32, 45, '/');//CCLabelTTF::labelWithString(ss.str().c_str(), "Arial", 30);
	lastgradeLabel->setScale(0.75);
	lastgradeLabel->setPosition(ccp(50 + lastGrade->getContentSize().width + 5, bgheight - 220));
	lastgradeLabel->setAnchorPoint(ccp(0, 0.5));
	bg->addChild(lastgradeLabel);
	ss.str("");
	ss.clear();

	if (PlayerMrg::getInstance()->getPlayer()->getPlayerGrade() > PlayerMrg::getInstance()->getPlayerLastHightGrade())
	{
		PlayerMrg::getInstance()->setPlayerLastHightGrade(PlayerMrg::getInstance()->getPlayer()->getPlayerGrade());
	}

	//chongxin kaishi
	std::string nameOne = "";
	nameOne = s_touchfile + s_language + "actor_btn_restart.png";
	CCMenuItemImage *pContinue = CCMenuItemImage::itemFromNormalImage(
		nameOne.c_str(),
		NULL,
		this,
		menu_selector(ResulitLayer::restartGame));
	pContinue->setPosition(ccp(bg->getContentSize().width / 2 - pContinue->getContentSize().width / 2 + 30, bgheight - 320));
	pContinue->setAnchorPoint(ccp(0, 0));
	pContinue->setScale(0.75);
	std::string str = s_touchfile + s_language + "actor_btn_exit.png";
	CCMenuItemImage *pExit = CCMenuItemImage::itemFromNormalImage(
		str.c_str(),
		NULL,
		this,
		menu_selector(ResulitLayer::menuExitCallBack));
	pExit->setPosition(ccp(bg->getContentSize().width / 2 - pExit->getContentSize().width / 2 + 30, bgheight - 390));
	pExit->setScale(0.75);
	pExit->setAnchorPoint(CCPointZero);
	// create menu, it's an autorelease object
	CCMenu* pMenu = CCMenu::menuWithItems(pContinue, pExit, NULL);
	pMenu->setPosition(CCPointZero);
	bg->addChild(pMenu);

	return true;
}
示例#16
0
void IOSStoreLayer::initUI()
{
	//初始化背景
	m_pBg = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_bg.png").c_str());
	this->addChild(m_pBg, 1, bg_tag);
	m_pBg->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2));

	m_pKaibaoxiangNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str());
	m_pKaibaoxiangNode->ignoreAnchorPointForPosition(false);
	m_pKaibaoxiangNode->setAnchorPoint(ccp(0.5f, 0.5f));
	m_pKaibaoxiangNode->setContentSize(m_pBg->getContentSize());
	m_pKaibaoxiangNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2));
	m_pBuyStarNode = CCScale9Sprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"nodebg.png").c_str());
	m_pBuyStarNode->ignoreAnchorPointForPosition(false);
	m_pBuyStarNode->setAnchorPoint(ccp(0.5f, 0.5f));
	m_pBuyStarNode->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2));
	m_pBuyStarNode->setContentSize(m_pBg->getContentSize());

	m_pBg->addChild(m_pKaibaoxiangNode, 3, kaibaoxiang_node_tag);
	m_pBg->addChild(m_pBuyStarNode, 3, buystar_node_tag);

	m_pBgMenu = CCMenu::create();
	m_pBgMenu->setPosition(CCPointZero);
	m_pBg->addChild(m_pBgMenu, 2);

	//左上角提示背景
	CCSprite* pTip = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_tishi.png").c_str());
	m_pBg->addChild(pTip, 0, tip_bg_tag);
	pTip->setPosition(ccp(pTip->getContentSize().width/2 - 25,
		m_pBg->getContentSize().height-pTip->getContentSize().height/2 - 30));

	//左上角提示字符串
	CCLabelTTF* pTipStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_lefttop_juqing").c_str(), fontStr_katong, 24, CCSizeMake(210, 80), kCCTextAlignmentLeft);
	m_pBg->addChild(pTipStr, 1, lefttop_tip_str_tag);
	pTipStr->setPosition(ccp(pTip->getPositionX() + 20, pTip->getPositionY() - 25));
	pTipStr->setString("");

	//中间提示字符
	CCLabelTTF* pTipCenterStr = CCLabelTTF::create(LFStrings::getValue("ShangdiangTipStr_center_01").c_str(), fontStr_katong, 24);
	m_pBg->addChild(pTipCenterStr, 1, center_tip_str_tag);
	pTipCenterStr->setColor(ccc3(150, 60, 20));
	pTipCenterStr->setPosition(ccp(m_pBg->getContentSize().width/2,  m_pBg->getContentSize().height - 160));
	pTipCenterStr->setString("");
	
	//右边星星数
	CCLabelAtlas* lable = CCLabelAtlas::create(
		"0123456789",
		ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
		30, 47,//24
		'0');
	m_pBg->addChild(lable, 1, star_count_str_tag);
	lable->setScale(0.6f);
	char charStarCount[10] = {}; 
	int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
	sprintf(charStarCount, "%d", iStarCount);
	lable->setString(charStarCount);
	lable->setPosition(ccp(m_pBg->getContentSize().width - 120, m_pBg->getContentSize().height - 175));

	//右边字符
	CCSprite* pShuzi = CCSprite::create(ResManager::getManager()->getFilePathByLanguageType(g_seasonlayerPath+"season_amount.png").c_str());
	m_pBg->addChild(pShuzi, 1);
	pShuzi->setScale(0.6f);
	pShuzi->setPosition(ccp(lable->getPositionX() - 50, pTipCenterStr->getPositionY()));

	//右边星星图标
	CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
	m_pBg->addChild(pXingxing, 1);
	pXingxing->setPosition(ccp(pShuzi->getPositionX() - 50, pShuzi->getPositionY()));
}
示例#17
0
void SecondLevel::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
	CCPoint p = touch->getLocation();
	if (!isRemoved && (p.x > 218 && p.x < 250) && (p.y > 30 && p.y < 59))
	{
		CCFadeOut *fadeOut = CCFadeOut::create(1.0f);
		rule_img->runAction(CCSequence::create(fadeOut, NULL));
		forward_button->runAction(CCSequence::create((CCFadeOut*)fadeOut->copy()->autorelease(), CCCallFunc::create(this, callfunc_selector(SecondLevel::fadeOutCallback)), NULL));
	}

	CCDictionary *dict = CCDictionary::createWithContentsOfFile("/word/words.xml");
	const char *win_word = ((CCString*)dict->objectForKey("win"))->m_sString.c_str();
	const char *lose_word = ((CCString*)dict->objectForKey("lose"))->m_sString.c_str();
	if (p.x >313 && p.x <364 && p.y > 94 && p.y < 155)
	{
		//right

		int level = userDefault->getIntegerForKey("level");
		if (level == 2)
			level++;
		userDefault->setIntegerForKey("level", level);

		int score = userDefault->getIntegerForKey("score");
		score += 5;
		userDefault->setIntegerForKey("score", score);

		CCLabelTTF *win = CCLabelTTF::create(win_word, "Arial", 24);
		win->setColor(ccc3(255, 0, 0));
		win->setPosition(ccp(150, 150));
		result->addChild(win);

		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));
		isDone = true;


	}
	else if (!isDone && (p.x > 47 && p.x < 98 && p.y > 166 && p.y < 225) ||
		(p.x > 113 && p.x < 164 && p.y > 166 && p.y < 225) ||
		(p.x > 181 && p.x < 232 && p.y > 166 && p.y < 225) ||
		(p.x > 247 && p.x < 297 && p.y > 166 && p.y < 225) ||
		(p.x > 313 && p.x < 364 && p.y > 166 && p.y < 225) ||
		(p.x > 380 && p.x < 431 && p.y > 166 && p.y < 225) ||
		(p.x > 47 && p.x < 98 && p.y > 94 && p.y < 155) ||
		(p.x > 113 && p.x < 164 && p.y > 94 && p.y < 155) ||
		(p.x > 181 && p.x < 232 && p.y > 94 && p.y < 155) ||
		(p.x > 247 && p.x < 297 && p.y > 94 && p.y < 155) ||
		(p.x > 380 && p.x < 431 && p.y > 94 && p.y < 155))
	{
		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));
		isDone = true;

	}
	if (isDone && p.x > 129 && p.x < 172 && p.y > 101 && p.y < 132)
	{
		CCDirector::sharedDirector()->replaceScene(SelectLevel::scene());
	}

}
示例#18
0
void GameScene::showOverView()
{
    if (m_pOverLayer == NULL)
    {
        m_pOverLayer = LGLayerColor::create(ccc4(0, 0, 0, 0));
        m_pOverLayer->retain();
        m_pOverLayer->setTouchMode(kCCTouchesOneByOne);
        m_pOverLayer->setTouchEnabled(true);
        m_pOverLayer->setZOrder(3);

        CCSprite *pTitle = CCSprite::create("title_over.png");
        pTitle->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.76f));
        m_pOverLayer->addChild(pTitle);

        CCSprite *pBgScore = CCSprite::create("bg_score.png");
        //pBgScore->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.535f));
        pBgScore->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y - pBgScore->getContentSize().height / 2));
        pBgScore->setTag(kTagOverScoreBoard);
        m_pOverLayer->addChild(pBgScore);

        float bgW = pBgScore->getContentSize().width, bgH = pBgScore->getContentSize().height;

        int record = CCUserDefault::sharedUserDefault()->getIntegerForKey("record", 0);
        if (record < m_CurrentScore)
        {
            record = m_CurrentScore;
            CCUserDefault::sharedUserDefault()->setIntegerForKey("record", record);
            NativeBridge::submitScore(record);

            CCSprite *indicatorNew = CCSprite::create("new.png");
            indicatorNew->setPosition(ccp(bgW * (0.5 - 0.2448980f), bgH * (0.5 - 0.08035714f)));
            pBgScore->addChild(indicatorNew);
        }

        CCLabelAtlas *current = CCLabelAtlas::create(CCString::createWithFormat("%d", m_CurrentScore)->getCString(), "fonts/font2.png", 36, 48, '0');
        current->setAnchorPoint(ccp(0.5, 0.5));
        current->setPosition(bgW / 2, bgH * 0.6394f);
        pBgScore->addChild(current);
        CCLabelAtlas *best = CCLabelAtlas::create(CCString::createWithFormat("%d", record)->getCString(), "fonts/font2.png", 36, 48, '0');
        best->setAnchorPoint(ccp(0.5, 0.5));
        best->setPosition(bgW / 2, bgH * (0.5 - 0.27679f));
        pBgScore->addChild(best);

        CCMenuItemImage *pRetry = LGMenuItemImage::create("retry.png", NULL, this, menu_selector(GameScene::retryCallback));
        CCMenuItemImage *pMenu = LGMenuItemImage::create("menu.png", NULL, this, menu_selector(GameScene::menuCallback));

        pRetry->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.73333333f, m_VisibleOrigin.y + m_VisibleSize.height * 0.285f));
        pMenu->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.26666667f, pRetry->getPositionY()));

        CCMenu *pCCMenu = CCMenu::create(pRetry, pMenu, NULL);
        pCCMenu->setTag(kTagOverMenu);
        pCCMenu->setAnchorPoint(CCPointZero);
        pCCMenu->setPosition(ccp(0, m_VisibleOrigin.y - (pRetry->getPositionY() - m_VisibleOrigin.y) * 2));
        m_pOverLayer->addChild(pCCMenu);
    }

    m_pOverLayer->getChildByTag(kTagOverScoreBoard)->runAction(CCMoveTo::create(0.5f, ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.535f)));
    m_pOverLayer->getChildByTag(kTagOverMenu)->runAction(CCMoveTo::create(1.0f, CCPointZero));

    if (m_pOverLayer && m_pOverLayer->getParent() == NULL)
    {
        getParent()->addChild(m_pOverLayer);
        CC_SAFE_RELEASE_NULL(m_CurrentLayer);
        m_CurrentLayer = m_pOverLayer;
        m_CurrentLayer->retain();
        onShowOverlay(true);
    }

    m_ScoreLabel->setVisible(false);
}
CCNode* DamageValueEffect::CreateCritDamageLable(unsigned int damage,CCPoint parentPos,bool isHarmFul)
{
	CCPoint uiPos = parentPos;
	CCSprite* critNode = CCSprite::create();
	critNode->setPosition(ccp(uiPos.x,uiPos.y));
	critNode->setAnchorPoint(ccp(0.5,0.5));

	ASprite *as = AspriteManager::getInstance()->getAsprite("UI/ui_inbattle.bin"); 
	CCPoint pt;
	int iFrameID = TXGUI::getResourceIDByName("map_ui_inbattle_FRAME_CRITICALBACK");
	CCSprite* critSprite = as->getSpriteFromFrame_Middle(iFrameID,0,pt);
	if(critSprite)
	{
		critSprite->setPosition(CCPointZero);
		critNode->addChild(critSprite,0);
	}

	char damageString[10];
	sprintf(damageString,"%d",damage);
	CCLabelAtlas* label;
	if(isHarmFul)
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_2.png",43,54,48);
	}
	else
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_3.png",41,43,48);
	}

	if(label)
	{
		label->setAnchorPoint(ccp(0.5f,0.5f));
		label->setPosition(CCPointZero);
		critNode->addChild(label,1);
		if(critSprite)
		{
			float scale_x = label->getContentSize().width / (0.8f * critSprite->getContentSize().width);
			float scale_y = label->getContentSize().height / (0.8f * critSprite->getContentSize().height);
			float scale = (scale_x > scale_y) ? scale_x : scale_y; 
			critSprite->setScale(scale);
			critSprite->setPosition(CCPointZero);
			critSprite->setAnchorPoint(ccp(0.5f,0.5f));
		}
	}

	critNode->setScale(0);
	critNode->runAction(getBattleUIAction());
	if(m_pDamageLabels->find(critNode) == m_pDamageLabels->end())
	{
		m_pDamageLabels->insert(make_pair(critNode,1.3f));
		//this->addChild(critNode);
		if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL
			&& GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer())
		{
			GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(critNode,MAP_Z_OBJ_TOP);
		}
	}

	/*if(isHarmFul)
	{
		HandleCritBurst(uiPos,0);
	}*/

	return critNode;
}
示例#20
0
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
    //srandom(0);

    subtestNumber = asubtest;
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    lastRenderedCount = 0;
    quantityParticles = particles;

    CCMenuItemFont::setFontSize(65);
    CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease));
    decrease->setColor(ccc3(0,200,20));
    CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease));
    increase->setColor(ccc3(0,200,20));

    CCMenu *menu = CCMenu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(s.width/2, s.height/2+15));
    addChild(menu, 1);

    CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(ccc3(0,200,20));
    infoLabel->setPosition(ccp(s.width/2, s.height - 90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // particles on stage
    CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
    addChild(labelAtlas, 0, kTagLabelAtlas);
    labelAtlas->setPosition(ccp(s.width-66,50));

    // Next Prev Test
    ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
    addChild(pMenu, 1, kTagMenuLayer);
    pMenu->release();

    // Sub Tests
    CCMenuItemFont::setFontSize(40);
    CCMenu* pSubMenu = CCMenu::create();
    for (int i = 1; i <= 6; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if (i <= 3)
        {
            itemFont->setColor(ccc3(200,20,20));
        }
        else
        {
            itemFont->setColor(ccc3(0,200,20));
        }
    }
    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(ccp(s.width/2, 80));
    addChild(pSubMenu, 2);

    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-32));
    label->setColor(ccc3(255,255,40));

    updateQuantityLabel();
    createParticleSystem();

    schedule(schedule_selector(ParticleMainScene::step));
}
示例#21
0
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// 	CHero *hero = m_currHeroList->at(uIdx);
	CSign &sign = m_signData.signList.at(uIdx);
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	pCell->setScale(0.97f);

	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
	}


	CImageView *imagView = (CImageView*)pCell->getChildByTag(1);	
	imagView->setTouchEnabled(true);
	imagView->setEnabled(true);
	imagView->setUserData(&m_signData.signList.at(uIdx));
	imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
	


	CCSprite *item = nullptr;
	if (sign.prize.thumb>=0)
	{
		CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
		SmartSetRectPrizeColor(pMask, &sign.prize);
		item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}
示例#22
0
void IOSStoreLayer::showItemsNode()
{
	int iTotalCount = 1;
	int iPrice = 10;
	int xcount = 1;
	int ycount = 1;
	CCSize size = CCSizeMake(120, 190);

	if (m_bBaoxiangBuyTenTimes)
	{
		iTotalCount = 10;
		size.width = 820;
		size.height = 350;
		xcount = 5;
		ycount = 2;
		iPrice = 95;
	}

	iTotalCount = this->getKaiBaoxiangRsqData().size();
	if (iTotalCount >= 11)
	{
		xcount = 6;
	}

	if (iTotalCount == 2)
	{
		xcount = 2;
		size = CCSizeMake(140*2, 190);
	}

	IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
	m_pGetItemNode->addChild(pView);
	pView->ignoreAnchorPointForPosition(false);
	pView->setAnchorPoint(ccp(0.5f, 0.5f));
	pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
	pView->setClickableCreater(pView);
	pView->prepareToDisplay();
	pView->setTouchEnabled(false);
	pView->setTag(getitem_scrollview_tag);

	//显示
	CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
	m_pGetItemNode->addChild(pSmallbg, 1);
	pSmallbg->setPosition(ccp(200, 100));

	//添加菜单
	CCMenu* pMenu = CCMenu::create();
	pMenu->setPosition(CCPointZero);
	m_pGetItemNode->addChild(pMenu, 2);
	
	//再开按钮
	CCMenuItemImage* pItem = NULL;
	int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
	if (m_bBaoxiangBuyTenTimes)
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_ten_again);
	}
	else
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_one_again);
	}
	pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30, 
		pSmallbg->getPositionY()));
	pMenu->addChild(pItem);

	//星星数量
	CCLabelAtlas* lable = CCLabelAtlas::create(
		"0123456789",
		ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
		30, 47,//24
		'0');
	m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
	lable->setAnchorPoint(ccp(0, 0.5));
	lable->setScale(0.6f);
	int iCount = 10;
	if (m_bBaoxiangBuyTenTimes)
	{
		iCount = 95;
	}
	char charStarCount[10] = {}; 
	sprintf(charStarCount, "%d", iCount);
	lable->setString(charStarCount);
	lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));

	//右边星星图标
	CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
	m_pGetItemNode->addChild(pXingxing, 1);
	pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));

	//星星数不够时,只显示确定按钮
	//确定按钮
	CCMenuItemImage* pOKItem = CCMenuItemImage::create(
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi.png").c_str(),
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi_select.png").c_str(),
		this, menu_selector(IOSStoreLayer::menuBtnCallBack));
	pOKItem->setTag(ok_btn_tag);
	pOKItem->setPosition(ccp(this->getContentSize().width/2 + pOKItem->getContentSize().width, pSmallbg->getPositionY()));
	pMenu->addChild(pOKItem);

	if (iStarCount < iPrice)
	{
		lable->setVisible(false);
		pXingxing->setVisible(false);
		pSmallbg->setVisible(false);
		pItem->setVisible(false);

		pOKItem->setPosition(ccp(this->getContentSize().width/2, pSmallbg->getPositionY()));
	}
	pMenu->setTouchPriority(kCCMenuHandlerPriority-5);
}