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);
    }
}
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;
}
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;
}
Esempio n. 4
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;
}
Esempio n. 5
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()));
}
Esempio n. 6
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);
}