예제 #1
0
void GameLayer::CheckWin()
{
	int iWin = 0;
	TouchSprite* Card;
	for (int k = 0; k< spCard.size(); k++)
	{
		Card = (TouchSprite*)spCard.at(k);
		if (Card->getTag() == 999){
			iWin++;
		}
	}
	if (iWin == spCard.size())
	{
		//well , you win
		//Card->GameWinJump();
		Card->unschedule(schedule_selector(GameLayer::updateTimeLabel));
		Card->scheduleOnce(schedule_selector(TouchSprite::GameWinJump), 1.0f);
	}
}
예제 #2
0
void GameLayer::UseTips()
{
	//Find a set of matched cards, Game them
	int iCardNo = 0;
	int iCardMatch = 0;

	TouchSprite* Card;
	TouchSprite* MatchCard;
	for (int i = 0; i < iMaxCard; i++)
	{
		Card = (TouchSprite*)spCard.at(i);
		if (Card->getTag() != 999)
		{
			iCardNo = i;
			break;
		}
	}
	for (int i = iCardNo + 1; i < iMaxCard; i++)
	{
		MatchCard = (TouchSprite*)spCard.at(i);
		if (Card->getTag() == MatchCard->getTag() || Card->getTag() - 1000 == MatchCard->getTag() || Card->getTag() + 1000 == MatchCard->getTag())
		{
			iCardMatch = i;
			break;
		}
	}
	//iCardMatch=FindMatch(iCardNo);
	if (iCardMatch>iCardNo)//found
	{
		int i = Card->getTag() % 1000;
		char file[100];
		//sprintf(file, "match_game_img_%d.jpg", i);
		//file[20] = '\0';
		sprintf(file, "%s", sFile[i - 1]);
		//Card = (TouchSprite*)spCard.at(iCardNo);
		//MatchCard = (TouchSprite*)spCard.at(iCardMatch);
		Card->setTag(999);
		MatchCard->setTag(999);
		Card->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));
		Card->setScaleX(0.9);
		Card->setScaleY(0.97);
		MatchCard->setDisplayFrame(SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(file));
		MatchCard->setScaleX(0.9);
		MatchCard->setScaleY(0.97);
	}
	CheckWin();
}