void AchievementNotification::showImmediately(Achievement a)
{
	mShowing = true;
	CCTexture2D* tex = CCTextureCache::sharedTextureCache()->textureForKey(fileName.c_str());
	if (tex == NULL)
	{
		tex = CCTextureCache::sharedTextureCache()->addImage(fileName.c_str());
	}
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();


	CCScale9Sprite* pBoard = CCScale9Sprite::create(CCRectMake(tex->getContentSize().width/2, 0, 2, tex->getContentSize().height), fileName.c_str());
	addChild(pBoard,0,Tag_Board);
	pBoard->setPosition(ccp(winSize.width/2,winSize.height + pBoard->getContentSize().height) );

	CCSprite* pJinBei = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_jiangbei.png").c_str());
	pBoard->addChild(pJinBei, 1);
	pJinBei->setPosition(ccp(pJinBei->getContentSize().width, pBoard->getContentSize().height/2));

	CCLabelTTF* pName = CCLabelTTF::create(a.name.c_str(), fontStr_KlavikaBold, 40);
	pName->setColor(fontColor_Acheivement_TTF);
	CCSprite* pIcon = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_wancheng.png").c_str());
	int x = pName->getContentSize().width + pIcon->getContentSize().width - 420;
	if (x > 0)
	{
		pBoard->setContentSize(ccp(pBoard->getContentSize().width+x, pBoard->getContentSize().height));
	}
	pBoard->addChild(pName);

	int xoffset = 10;

	pName->setPosition(ccp(pBoard->getContentSize().width/2 + pIcon->getContentSize().width/2 + xoffset, pBoard->getContentSize().height/2));

	pBoard->addChild(pIcon);
	pIcon->setPosition(ccp(pName->getPositionX() - pName->getContentSize().width/2 - pIcon->getContentSize().width/2 - xoffset, pName->getPositionY()));

	Achievement* achievementCopy = new Achievement(a);
//	*achievementCopy = a;
	temp_Must_Delete.insert(temp_Must_Delete.end(),achievementCopy);

	pBoard->runAction(CCSequence::create(
		CCMoveTo::create(0.5f,ccp(pBoard->getPositionX(),winSize.height-pBoard->getContentSize().height/2)),
		CCDelayTime::create(0.1f),
		CCCallFuncND::create(this,SEL_CallFuncND(&AchievementNotification::boardShowing),achievementCopy),
		CCDelayTime::create(1.3f),
		CCMoveTo::create(0.2f,ccp(pBoard->getPositionX(),winSize.height+pBoard->getContentSize().height)),
		CCFadeTo::create(0.1f,0),
		CCCallFuncN::create(this,SEL_CallFuncN(&AchievementNotification::boardShowEnd)),NULL));

	createPar(ccp(winSize.width/2,winSize.height),parFileName.c_str(),pBoard->getContentSize().width * 1.2f,pBoard->getContentSize().height);

	Music::sharedMusicPlayer()->playEffectSound("achievement.wav");

	CCLog("AchievementNotification::showImmediately name = %s" ,a.name.c_str());
}
Exemple #2
0
LFToast::LFToast(string msg,float during)
{
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCScale9Sprite* base = CCScale9Sprite::create("toast.png");
	CCLabelTTF* lable = CCLabelTTF::create(
		msg.c_str(),
		fontStr_kaiti,
		30,
		CCSize(base->getContentSize().width - 10,0), 
		kCCTextAlignmentLeft);
	lable->setAnchorPoint(ccp(0,0.5f));
	addChild(base);
	base->setContentSize(CCSizeMake(base->getContentSize().width,lable->getContentSize().height + 20));
	base->setOpacity(0);
	base->addChild(lable);
	lable->setPosition(ccp(10,base->getContentSize().height/2));
	base->setPosition(ccp(visibleSize.width/2,base->getContentSize().height + 20));
	base->runAction(CCSequence::create(
		CCFadeTo::create(0.2f,255),
		CCDelayTime::create(during),
		CCFadeTo::create(0.1f,0),
		CCCallFuncN::create(this,SEL_CallFuncN(&LFToast::removeToast)),
		NULL
		));
}
void ArenaWindow::recv_3700()
{
    Message *revMsg=(Message *)CData::getCData()->m_dictionary->objectForKey(3700);
    CData::getCData()->m_dictionary->removeObjectForKey(3700);
    
    
    if(revMsg)
    {
        load->removeFromParent();
        
        this->unschedule(schedule_selector(ArenaWindow::recv_3700));
        char* data=revMsg->data;
        CCLog("%s",data);
        Json::Reader read;
        Json::Value root;
        Json::Value jsonData;
        Json::Value petlist;
        
        
        if(read.parse(data, root)){
            
            CCSprite* sp = CCSprite::create();
            
            jsonData=root["data"];
            petlist=jsonData["dsList"];
            
            int sptimes = jsonData["sptimes"].asInt();
            
            char titlechar[100] = "";
            sprintf(titlechar, "当前排名:%d  今日挑战剩余次数:%d",jsonData["ranking"].asInt(),jsonData["sptimes"].asInt());
            CCLabelTTF* titel = CCLabelTTF::create(titlechar, "hycc.ttf", 22,CCSizeMake(400, 0),kCCTextAlignmentCenter);
            titel->setColor(ccc3(255, 219, 160));
            titel->setPosition(ccp(size.width/2, 600));
            this->addChild(titel);
            
            int len = petlist.size();
            
            for (int i=0; i<len; i++) {
                
                CCScale9Sprite* item = CCScale9Sprite::create("arena_item_bkg.png");
                item->setContentSize(CCSizeMake(410, 85));
                char rank[10] = "";
                sprintf(rank, "%d",jsonData["dsList"][i]["ranking"].asInt());
                CCLabelTTF* ranking = CCLabelTTF::create(rank, "hycc.ttf", 20,CCSizeMake(200, 0),kCCTextAlignmentCenter);
                //ranking->setColor(ccc3(255, 219, 160));
                ranking->setPosition(ccp(37, 42));
                item->addChild(ranking);
                
                CCLabelTTF* nickname = CCLabelTTF::create(jsonData["dsList"][i]["nickname"].asString().c_str(), "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft);
                nickname->setColor(ccc3(255, 219, 160));
                nickname->setAnchorPoint(ccp(0, 0));
                nickname->setPosition(ccp(85, 30));
                item->addChild(nickname);
                
                char levelchar[10] = "";
                sprintf(levelchar, "%d级",jsonData["dsList"][i]["level"].asInt());
                CCLabelTTF* level = CCLabelTTF::create(levelchar, "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft);
                level->setAnchorPoint(ccp(0, 0));
                level->setColor(ccc3(255, 219, 160));
                level->setPosition(ccp(180, 30));
                item->addChild(level);
                
                if (sptimes != 0) {
                    CCMenuItemImage* ok = CCMenuItemImage::create("arena_btn_bat_1.png", "arena_btn_bat_2.png", this, menu_selector(ArenaWindow::clk_battle));
                    ok->setTag(jsonData["dsList"][i]["characterId"].asInt());
                    CCMenu* menu = CCMenu::create();
                    menu->setAnchorPoint(ccp(0, 0));
                    menu->setPosition(ccp(370, 40));
                    menu->addChild(ok);
                    item->addChild(menu);
                }
                
                
                CCSprite* qsbkg = CCSprite::create("common_qs_bkg_4.png");
                qsbkg->setScale(1.0);
                
                int pro = jsonData["dsList"][i]["profession"].asInt();
                
                char prochar[20] = "";
                sprintf(prochar, "qs_%04d.png",pro);
                
                CCSprite* headsp = CCSprite::create(prochar);
                headsp->setScale(0.18);
                headsp->setAnchorPoint(ccp(0, 0));
                qsbkg->addChild(headsp);
                
                qsbkg->setPosition(ccp(265, 38));
                item->addChild(qsbkg);
                
                
                
                item->setAnchorPoint(ccp(0.5, 1));
                item->setPosition(ccp(0,-i*82));//82
                sp->addChild(item);

            }
            sp->setPosition(ccp(size.width/2, 560));
            this->addChild(sp);
        }
    }

}