void OrgRankList::showCntryDgRank()
{
    char buf[100];
    
    CCMutableArray<CCntryDgRankInfo* > * pRandLst = CGameData::Inst()->getCntryDgRankInfArr();
    int iItemCnt = pRandLst->count();

    CUserInfo* pUsrInf = CGameData::Inst()->getUsrInfo();
    for (int i = 0; i < iItemCnt; i++) {
        CCntryDgRankInfo* pInf = pRandLst->getObjectAtIndex(i);
        
        bool bIsMe = (pInf->strUid.compare(pUsrInf->uid) == 0);
        
        snprintf(buf, 99, "%d", i+1);
        CCLabelTTF* text = CCLabelTTF::labelWithString(buf, "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(30, 296 - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
        
        text = CCLabelTTF::labelWithString(pInf->strName.c_str(), "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(190, 296 - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
        
        snprintf(buf, 99, "%ld", pInf->lDamage);
        text = CCLabelTTF::labelWithString(buf, "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(426, 296 - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
    }
    
    
    string lastKillName = CGameData::Inst()->getCntryBossLastKillName();
    if (!lastKillName.empty())
    {
        CCLabelTTF* text1 = CCLabelTTF::labelWithString(lastKillName.c_str(), "STHeitiSC-Medium", 20);
        text1->setPositionInPixels(CCPointMake(30, 296 - iItemCnt * 22 - 10));
        text1->setAnchorPoint(ccp(0, 0.5));
        addChild(text1);
        text1->setColor(ccRED);
        CCLabelTTF* text2 = CCLabelTTF::labelWithString(CGameData::Inst()->getLanguageValue("orgft_last_kill"), "STHeitiSC-Medium", 20);
        text2->setPositionInPixels(CCPointMake(30 + text1->getContentSize().width + 6, text1->getPosition().y));
        text2->setAnchorPoint(ccp(0, 0.5));
        addChild(text2);
        
        iItemCnt += 2;
    }
    
    
    if (iItemCnt > 6) {
        m_fLimitY = (iItemCnt - 7) * 22 + 10;
        m_fBarBgPosY = 304;
        
        m_spScrollBg = CCSprite::spriteWithFile("rankscrollbg.png");
        if (m_spScrollBg) {
            addChild(m_spScrollBg);
            m_spScrollBg->setAnchorPoint(ccp(0, 1));
            m_spScrollBg->setPositionInPixels(ccp(600, m_fBarBgPosY));
            m_spScrollBg->setScaleY(0.72);
            
            m_spScrollBar = CCSprite::spriteWithFile("rankscrollbar.png");
            if (m_spScrollBar) {
                m_spScrollBg->addChild(m_spScrollBar);
                m_spScrollBar->setAnchorPoint(ccp(0, 1));
                m_spScrollBar->setPositionInPixels(ccp(5, m_fBarPos0));
            }
        }
    }
    else{
        m_fLimitY = 0;
    }
}
Beispiel #2
0
// on "init" you need to initialize your instance
bool PixelColorGame::init()
{
	if(CCLayer::init())
	{
		// Init scale features
		
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		scaleX = size.width / VIRTUAL_WIDTH;
		scaleY = size.height / VIRTUAL_HEIGHT;

		// Score
		
		ccColor3B cLabelColor = {24, 89, 140};
		CCLabelTTF* cLabel = CCLabelTTF::labelWithString("MOVES LEFT", "arial", 12);
		cLabel->setPositionInPixels(ccp(430.0f * scaleX, 59.0f * scaleY));
		cLabel->setColor(cLabelColor);
		addChild(cLabel);

		// Menu creation

		CCMenuItemImage *b1 = CCMenuItemImage::itemFromNormalImage((char*)buttons[(int)Blue].c_str(), (char*)buttons[(int)Blue].c_str(), this, menu_selector(PixelColorGame::BlueColorSelect) );
		CCMenuItemImage *b2 = CCMenuItemImage::itemFromNormalImage((char*)buttons[(int)Red].c_str(), (char*)buttons[(int)Red].c_str(), this, menu_selector(PixelColorGame::RedColorSelect));
		CCMenuItemImage *b3 = CCMenuItemImage::itemFromNormalImage((char*)buttons[(int)Yellow].c_str(), (char*)buttons[(int)Yellow].c_str(), this, menu_selector(PixelColorGame::YellowColorSelect));
		CCMenuItemImage *b4 = CCMenuItemImage::itemFromNormalImage((char*)buttons[(int)Orange].c_str(), (char*)buttons[(int)Orange].c_str(), this, menu_selector(PixelColorGame::OrangeColorSelect));
		CCMenuItemImage *b5 = CCMenuItemImage::itemFromNormalImage((char*)buttons[(int)Violet].c_str(), (char*)buttons[(int)Violet].c_str(), this, menu_selector(PixelColorGame::VioletColorSelect));

		CCMenu *menu = CCMenu::menuWithItems(b1, b2, b3, b4, b5, NULL);

		b1->setScaleX(scaleX);
		b1->setScaleY(scaleY);
		b1->setAnchorPoint(CCPointMake(0, 0));
		b1->setPositionInPixels(ccp(0, 0));

		b2->setScaleX(scaleX);
		b2->setScaleY(scaleY);
		b2->setAnchorPoint(CCPointMake(0, 0));
		b2->setPositionInPixels(ccp(b2->getContentSizeInPixels().width * scaleX, 0));

		b3->setScaleX(scaleX);
		b3->setScaleY(scaleY);
		b3->setAnchorPoint(CCPointMake(0, 0));
		b3->setPositionInPixels(ccp(b3->getContentSizeInPixels().width * scaleX * 2, 0));

		b4->setScaleX(scaleX);
		b4->setScaleY(scaleY);
		b4->setAnchorPoint(CCPointMake(0, 0));
		b4->setPositionInPixels(ccp(b4->getContentSizeInPixels().width * scaleX * 3, 0));

		b5->setScaleX(scaleX);
		b5->setScaleY(scaleY);
		b5->setAnchorPoint(CCPointMake(0, 0));
		b5->setPositionInPixels(ccp(b5->getContentSizeInPixels().width * scaleX * 4, 0));

		menu->setPosition(ccp(0.0f, 0.0f));
		addChild(menu, 1);

		// Matrix

		float currentLevelPieceWidth = VIRTUAL_WIDTH / levelColumns;
		float currentLevelPieceHeight = (VIRTUAL_HEIGHT - b1->getContentSizeInPixels().height) / levelRows;


		for(int x = 0; x < levelColumns; x++)
		{
			for(int y = 0; y < levelRows; y++)
			{
				int value = board.GetNumberColor(x,y);
				CCSprite *sprite = CCSprite::spriteWithFile(buttons[value].c_str());
				sprite->setAnchorPoint(CCPointMake(0, 0));
				sprite->setPositionInPixels(ccp(currentLevelPieceWidth * x * scaleX, (currentLevelPieceHeight * y + b1->getContentSizeInPixels().height + currentLevelPieceHeight) * scaleY));
				sprite->setScaleX(scaleX);
				sprite->setScaleY(scaleY);
				addChild(sprite);
			}

		}
	}

	

	return true;
}
void OrgRankList::showSpecialDgRank(string dgType)
{
    float fPosY = 30.0;
    char buf[100];
    
    CCMutableArray<CSpecialDgRankInfo* > * pRandLst = CGameData::Inst()->getSpecialDgRankInfArr(dgType);
    int iItemCnt = pRandLst->count();
            
    
    
    int myRank = CGameData::Inst()->getMySpecialDgRank(dgType);
    bool bAddMyRank = false;
    if (myRank > iItemCnt)
    {
        iItemCnt++;
        bAddMyRank = true;
    }
    CCountryInfo* pCntryInfo = CGameData::Inst()->getCntryInfo();
    for (int i = 0; i < iItemCnt; i++) {
        CSpecialDgRankInfo* pInf = NULL;
        if (bAddMyRank && i == iItemCnt - 1) {
            snprintf(buf, 99, "%d", myRank);
            pInf = CGameData::Inst()->getMySpecialDgRankInf(dgType);
        }
        else
        {
            snprintf(buf, 99, "%d", i+1);
            pInf = pRandLst->getObjectAtIndex(i);
        }
        
        bool bIsMe = (pInf->strCid.compare(pCntryInfo->cid) == 0);
        
        CCLabelTTF* text = CCLabelTTF::labelWithString(buf, "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(30, 296 - fPosY - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
        
        text = CCLabelTTF::labelWithString(pInf->strName.c_str(), "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(190, 296 - fPosY - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
        
        text = CCLabelTTF::labelWithString(pInf->strTime.c_str(), "STHeitiSC-Medium", 20);
        text->setPositionInPixels(CCPointMake(426, 296 - fPosY - i * 22));
        text->setAnchorPoint(ccp(0, 0.5));
        if(bIsMe)
            text->setColor(ccc3(249, 196, 15));
        else
            text->setColor(ccc3(255, 255, 255));
        addChild(text);
    }
        
    if (iItemCnt > 5) {
        m_fLimitY = (iItemCnt - 6) * 22 + 16;
        m_fBarBgPosY = 276;
        
        m_spScrollBg = CCSprite::spriteWithFile("rankscrollbg.png");
        if (m_spScrollBg) {
            addChild(m_spScrollBg);
            m_spScrollBg->setAnchorPoint(ccp(0, 1));
            m_spScrollBg->setPositionInPixels(ccp(600, m_fBarBgPosY));
            m_spScrollBg->setScaleY(0.58);
            
            m_spScrollBar = CCSprite::spriteWithFile("rankscrollbar.png");
            if (m_spScrollBar) {
                m_spScrollBg->addChild(m_spScrollBar);
                m_spScrollBar->setAnchorPoint(ccp(0, 1));
                m_spScrollBar->setPositionInPixels(ccp(5, m_fBarPos0));
            }
        }
    }
    else{
        m_fLimitY = 0;
    }
}