예제 #1
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;
}
예제 #2
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;
}
예제 #3
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;
	}
예제 #4
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;
}
예제 #5
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;
}
예제 #6
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;
}
예제 #7
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);
	}
}