Example #1
0
void LayerGoods::updateMe()
{
	UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();

	CCMenu* menu = static_cast<CCMenu*>(this->getChildByTag(0));
	//体魄
	int goods_level = 0;
	CCMenuItemSprite* item = NULL;
	CCSprite* sprite = NULL;
	CCLabelAtlas* la = NULL;
	for (int i = 1; i <= 5; i++)
	{
		if (i == 1)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelTiPo());
		}
		else if (i == 2)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelMeiLi());
		}
		else if (i == 3)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelZhiLi());
		}
		else if (i == 4)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelEQ());
		}
		else if (i == 5)
		{
			goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelGanXing());
		}
		item = static_cast<CCMenuItemSprite*>(menu->getChildByTag(i));
		if (goods_level >= 9)
		{
			item->setEnabled(false);
			item->setColor(ccc3(128, 128, 128));
		}
		sprite = static_cast<CCSprite*>(this->getChildByTag(i));
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(0));
		la->setString(CCString::createWithFormat("%d", goods_level)->getCString());
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(1));
		la->setString(CCString::createWithFormat("%d", getGoodsBonus(goods_level))->getCString());
		la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
		la->setString(CCString::createWithFormat("%d", getGoodsPrice(goods_level))->getCString());
	}

	SceneMain* scene_main = static_cast<SceneMain*>(CCDirector::sharedDirector()->getRunningScene()->getChildByTag(0));
	scene_main->updateMe();
}
Example #2
0
void MarketScene::updateLabelAtlas(int num, int tag)
{
	char txt[32] = { 0 };
	sprintf(txt, "%d", num);
	CCLabelAtlas *label = (CCLabelAtlas *)getChildByTag(tag);
	label->setString(txt);
}
void GameTipsSprite::setStageNum(int num){
	CCLabelAtlas* stagenumbrer =(CCLabelAtlas*) this->getChildByTag(4);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	stagenumbrer->setString(temp);
	delete temp;
}
Example #4
0
void RatingSprite::setLeverNum(int num){
    CCLabelAtlas* numbrer =(CCLabelAtlas*) this->getChildByTag(2);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	numbrer->setString(temp);
	delete temp;
}
void GameTipsSprite::setMonstTotalNum(int num){
	CCLabelAtlas* monsttotalnumbrer =(CCLabelAtlas*) this->getChildByTag(3);
	char* temp=new char[12];
	sprintf(temp,"%d",num);
	monsttotalnumbrer->setString(temp);
	delete temp;
}
Example #6
0
CCSprite* LevelScene::addMapBtnWith(int no, cocos2d::CCPoint pos, CCSpriteBatchNode* batch)
{
    CCSprite *map = NULL;
    CCSprite *lockSprite = NULL;
    CCLabelAtlas *mapNo = CCLabelAtlas::create("0123456789", "fonts_score_002-hd.png", 38, 44, '0');

    if (FruitCrush::shareSingleton()->canPlayMap(no)) {
        map = CCSprite::createWithTexture(batch->getTexture());
        map->setTag(no);
        //map->setScale(0.6);
        CCString* num = CCString::createWithFormat("%u", no);
        mapNo->setString(num->getCString());
        //mapNo->setColor(ccc3(242, 247, 240));
        mapNo->setAnchorPoint(ccp(0.5f,0.5f));
        mapNo->setPosition(ccp(map->boundingBox().size.width/2, map->boundingBox().size.height/2));
        map->addChild(mapNo);
        //this->addChild(mapNo);
    }
    else
    {
        
    }
    
    map->setPosition(pos);
    map->setScale(0.8);
    this->addChild(map);
    return map;
    
}
void ParticleMainScene::step(float dt)
{
    CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas);
    CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem);

    char str[10] = {0};
    sprintf(str, "%4d", emitter->getParticleCount());
    atlas->setString(str);
}
Example #8
0
void IOSStoreLayer::setStarCount(int num)
{
	CCLabelAtlas* pTipStr = (CCLabelAtlas*)m_pBg->getChildByTag(star_count_str_tag);
	if (pTipStr)
	{
		pTipStr->setString(CCString::createWithFormat("%d", num)->getCString());
	}
	this->setKaiBaoxiangBtnVisiable();
}
Example #9
0
void ParticleDemo::step(ccTime dt)
{
    if (m_emitter)
    {
	    CCLabelAtlas* atlas = (CCLabelAtlas*)getChildByTag(kTagLabelAtlas);
        char str[5] = {0};
        sprintf(str, "%04d", m_emitter->getParticleCount());
	    atlas->setString(str);
    }
}
Example #10
0
void CWaterpump::ResetAxeNum(cocos2d::CCMenuItemSprite *pItem, int num)
{
    CCLabelAtlas *pItemFnt = dynamic_cast<CCLabelAtlas*>(pItem->getChildByTag(Tag_ItemFnt));
    if (NULL != pItemFnt)
    {
        char szNum[8] = {0};
        sprintf(szNum, "%d", num);
        pItemFnt->setString(szNum);
    }
}
Example #11
0
void ScoreCenter::showPromptScore(int score, CCPoint ppoint)
{
    CCString* curScore = CCString::createWithFormat("%u", score);
    CCLabelAtlas* label = ResCenter::shareInstance()->getLableAtlasByType(ResCenter::klableScore);
    label->setPosition(ppoint);
    //label->setScale(0.5);
    label->setString(curScore->getCString());
    
    CCFiniteTimeAction* sf = ActionEffectHub::shareInstance()->scoreFly();
    CCFiniteTimeAction* cb = CCCallFuncN::create(this, callfuncN_selector(ScoreCenter::_removeScorePrompt));

    CCSequence* cbSeq = CCSequence::create(sf, cb, NULL);
    label->runAction(cbSeq);
    this->getLayer()->addChild(label);
}
Example #12
0
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// 	CHero *hero = m_currHeroList->at(uIdx);
	CSign &sign = m_signData.signList.at(uIdx);
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	pCell->setScale(0.97f);

	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
	}


	CImageView *imagView = (CImageView*)pCell->getChildByTag(1);	
	imagView->setTouchEnabled(true);
	imagView->setEnabled(true);
	imagView->setUserData(&m_signData.signList.at(uIdx));
	imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
	


	CCSprite *item = nullptr;
	if (sign.prize.thumb>=0)
	{
		CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
		SmartSetRectPrizeColor(pMask, &sign.prize);
		item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}
void SectionItem::initButton(SectionItem* button,bool canChoose)
{
	button->canChoose = canChoose;
	ResManager* resMgr = ResManager::getManager();
	
	if (!canChoose)
	{
		initWithFile(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_lock_bg.png").c_str());
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data))
		{
			CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
			addChild(img);
			img->setPosition(ccp(getContentSize().width-7, getContentSize().height));
		}
*/
	}else
	{
		char fileName[128];
		sprintf(fileName, (resMgr->getSharedFilePath()+g_seasonlayerPath+"sectionItem_%d_bg.png").c_str(),button->currentScore);
		initWithFile(fileName);
		if (button->currentScore == 0)
		{
			CCSprite *ef = CCSprite::create(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_new_bg.png").c_str());
			addChild(ef);
			ef->setPosition(ccp(ef->getContentSize().width/2, ef->getContentSize().height/2 - 3));
			ef->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.5f), CCFadeIn::create(1.5f), NULL)));
		}
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state != DJS_NotGetted)
		{
			CCSprite *img = CCSprite::create(resMgr->getSharedFilePath(g_daojuPath+data.fileName).c_str());
			addChild(img);
			img->setPosition(ccp(getContentSize().width/2, 120));
			img->setScale(0.75f);
		}
		*/
		if (false)
		{
		}
		else 
		{
	
			CCLabelAtlas* lable = CCLabelAtlas::create(
				"0123456789",
				resMgr->getSharedFilePath(g_seasonlayerPath+"season_section_num.png").c_str(),
				40, 49,//24
				'0');
			addChild(lable);
			char id[5];
			sprintf(id,"%d",button->sectionId);
			lable->setString(id);
			lable->setPosition(ccp(getContentSize().width/2 - lable->getContentSize().width/2,90));
			
			//屏蔽剧情道具相关
/*			if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state == DJS_NotGetted)
			{
				CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
				addChild(img);
				img->setPosition(ccp(getContentSize().width-5, getContentSize().height+10));

				CCAnimation *animation = CCAnimation::create();
				for (int idx=1; idx<=16; ++idx){
					animation->addSpriteFrameWithFileName(CCString::createWithFormat("sectionItem_daoju_weihuode_%d.png", idx)->getCString());
				}
				animation->setDelayPerUnit(0.02f);
				img->runAction(CCRepeatForever::create(CCSequence::create(CCAnimate::create(animation), CCDelayTime::create(1), NULL)));
			}
*/
		}
	}
}
Example #14
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()));
}
Example #15
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);
}
void GameScene::update(float dt) {
    CCSprite* bird = (CCSprite*)getChildByTag(TAG_BIRD);
    
    if (bird->getPositionY() >= screenSize.height) {
        bird->setPositionY(screenSize.height);
    }
    
    CCRect birdRect = CCRectMake(bird->getPositionX() - bird->getContentSize().width * 0.45f, bird->getPositionY() - bird->getContentSize().height * 0.45f,
                                 bird->getContentSize().width * 0.9f, bird->getContentSize().height * 0.9f);
    
    
    if (isGameOver) {
        CCSprite* land = (CCSprite*)getChildByTag(TAG_LAND);
        CCRect landRect = CCRectMake(land->getPositionX(), land->getPositionY(),
                                     land->getContentSize().width * 0.9f, land->getContentSize().height * 0.97f);
        if (landRect.intersectsRect(birdRect)) {
            bird->stopAllActions();
            unscheduleUpdate();
            showGameOver();
        }
        return;
    }
    
    CCSprite* land = (CCSprite*)getChildByTag(TAG_LAND);
    CCRect landRect = CCRectMake(land->getPositionX(), land->getPositionY(),
                                 land->getContentSize().width * 0.9f, land->getContentSize().height * 0.97f);
    if (landRect.intersectsRect(birdRect)) {
        isGameOver = true;
        bird->stopAllActions();
        unscheduleAllSelectors();
        
        CCShake* shake = CCShake::create(0.6f, 15);
        runAction(shake);
        M3AudioManager::shareInstance()->playSound(SOUND_HIT);
        
        for (int i = 0; i < hitCheckArray->count(); i++) {
            CCSprite* pipe = (CCSprite*)hitCheckArray->objectAtIndex(i);
            pipe->stopAllActions();
        }
        CCSprite* land = (CCSprite*)getChildByTag(TAG_LAND);
        land->stopAllActions();
        
        showGameOver();
        return;
    }
    

    
    for (int i = 0; i < hitCheckArray->count(); i++) {
        CCSprite* pipe = (CCSprite*)(hitCheckArray->objectAtIndex(i));
        CCRect pipeRect = CCRectMake(pipe->getPositionX() - pipe->getContentSize().width * 0.45f, pipe->getPositionY() + screenSize.height * 0.03f,
                                     pipe->getContentSize().width * 0.9f, pipe->getContentSize().height * 0.925f);
        if (pipeRect.intersectsRect(birdRect)) {
            CCShake* shake = CCShake::create(0.6f, 15);
            runAction(shake);
            M3AudioManager::shareInstance()->playSound(SOUND_HIT);
            gameOver();
            return;
        }
    }
    
    
    for (int i = 0; i < pipeArray->count(); i++) {
        CCSprite* pipe = (CCSprite*)(pipeArray->objectAtIndex(i));
        int uData = (int)pipe->getUserData();
        if (uData == 0 && pipe->getPositionX() <= screenSize.width * 0.25f) {
            pipe->setUserData((void*)1);
            
            gameScore += 1;
            CCLabelAtlas* score = (CCLabelAtlas*)getChildByTag(999);
            score->setString(CCString::createWithFormat("%d", gameScore)->getCString());
            
            M3AudioManager::shareInstance()->playSound(SOUND_MUSIC);
            
            if (gameScore == 15) {
                CCSprite* glass = CCSprite::createWithSpriteFrameName("glass.png");
                glass->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
                addChild(glass, 100);
                
                CCDelayTime* delay = CCDelayTime::create(2.0f);
                CCCallFuncN* c = CCCallFuncN::create(this, callfuncN_selector(GameScene::removeGlass));
                CCSequence* seq = CCSequence::create(delay, c, NULL);
                glass->runAction(seq);
                
                M3AudioManager::shareInstance()->playSound(SOUND_HIT);
            }
            break;
        }
    }
}