Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 2
0
Letter::Letter(char letter, size_t id): letter(toupper(letter)), id(id){
	// TODO - нужно либо делать rect метод чтобы правильный размер сделать
	// либо он на автомате будет работать. я не знаю
	CCSprite::init();
	//this->setTouchEnabled(true);
	this->autorelease();

	// TODO 1 раз получать - для всех использовать потом
	letterImage = CCSprite::create("letter32_2.png");
	letterImage->setScale(32 / letterImage->getContentSize().width);
	char arr[2] = {this->letter, '\0'};


	//CCLabelTTF *letterLabel = CCLabelTTF::create(arr, "fonts/Schwarzwald Regular.ttf", 22);
	//CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize,
	//                                      blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]);

	//CCLabelTTF *letterLabel = CCLabelTTF::create(arr, /*"fonts\sylfaen.ttf"*/"Sylfaen", 50);


	//CCLabelBMFont *letterLabel = CCLabelBMFont::create(arr, "fonts/hd/markerFelt.fnt", 10);
	//letterLabel->setScale(0.5);

	CCLabelAtlas *letterLabel = CCLabelAtlas::create(arr, "fonts/hd/larabie-16.plist");
	letterLabel->setAnchorPoint(ccp(0.5f, 0.5f));
	letterLabel->setColor(ccc3(85,47,17));
	//letterLabel->setColor(ccc3(0,0,0));

	this->addChild(letterImage,1);
	this->addChild(letterLabel,2);
}
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;
}
Exemplo n.º 4
0
ItemCard* ItemCard::spriteWithFile(const char *normalImage, string id, short cardNum)
{
    ItemCard* pRet = new ItemCard(id, cardNum);
    
    if ((normalImage == NULL) || (*normalImage == 0)) {
        normalImage = "box_none.png";
    }
    
    if (pRet && pRet->initWithFile(normalImage))
    {
        pRet->autorelease();
        
        char buf[30];
        sprintf(buf, "/%d",cardNum);
        
        CCSprite* spTmp = CCSprite::spriteWithFile("rewardnum.png");
        if(spTmp){
            CCSize sz = spTmp->getContentSize();
            CCLabelAtlas* textNum = CCLabelAtlas::labelWithString(buf,
                                                                      "rewardnum.png",
                                                                      sz.width / 11,
                                                                      sz.height,
                                                                      '/');
            textNum->setAnchorPoint(ccp(0.5, 0.5));
            textNum->setPosition(ccp(54,10));
            pRet->addChild(textNum,0,9);
        }
        
        return pRet;
    }
    
    CC_SAFE_DELETE(pRet);
    return NULL;
}
Exemplo n.º 5
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;
    
}
Exemplo n.º 6
0
//******************************************************************************
// useAutoSkill
//******************************************************************************
void Card::useAutoSkill(float fEffect, int iBaoJi)
{
    float fDur = 0.0;
    
    if(fEffect < -2.0){
        fDur = 0.3;
    }
    else if(fEffect < 0.0){
        fDur = 0.1;
    }
    else{
        m_AtkInfo.iAttackPt *= fEffect;
        m_numAtkVal->setNumber(m_AtkInfo.iAttackPt, 0.6, 0.0);
        
        fDur = 0.3;
    }
    
    CCPoint ptSrc = CCPointMake(0, 0);
    if (getCD() == 0)
        ptSrc = CCPointMake(0, 8);
    CCPoint ptDst = CCPointMake(ptSrc.x, ptSrc.y + 8);
    
    this->stopAllActions();
    this->setPositionInPixels(ptSrc);
    this->runAction(CCSequence::actions(CCMoveTo::actionWithDuration(fDur, ptDst),
                                        CCMoveTo::actionWithDuration(fDur, ptSrc),
                                        NULL));
    
    if (iBaoJi > 0) {
        CCSprite* spBaojiBg = CCSprite::spriteWithSpriteFrameName("baojibg.png");
        if (spBaojiBg) {
            spBaojiBg->setAnchorPoint(CCPointMake(0.5, 0));
            spBaojiBg->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            addChild(spBaojiBg,0,kToBeDeleteTag);
        }
        
        CCSprite *sp = CCSprite::spriteWithFile("baojinum.png");
        if (sp) {
            char buf[10];
            snprintf(buf, 9, "/%d", iBaoJi);
            CCLabelAtlas *lbb = CCLabelAtlas::labelWithString(buf,
                                                              "baojinum.png",
                                                              sp->getContentSize().width / 11,
                                                              sp->getContentSize().height, '/');
            lbb->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            lbb->setAnchorPoint(CCPointMake(0.5, 0));
            addChild(lbb,0,kToBeDeleteTag);
            
            lbb->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(fDur*2),
                                               CCCallFunc::actionWithTarget(this, callfunc_selector(Card::delUnusedObj)),
                                               NULL));
        }
    }
}
Exemplo n.º 7
0
CCLabelAtlas* ResCenter::getLableAtlasByType(ResCenter::typeLableAtlas type)
{
    switch (type) {
        case klableScore:
        {
            CCLabelAtlas* lable = CCLabelAtlas::create("0123456789", "fonts_roulette_001-hd.png", 24, 32, '0');
            lable->setAnchorPoint(ccp(0.5, 0.5));
            return lable;
            break;
        }
            
            
        default:
            break;
    }
}
Exemplo n.º 8
0
CCMenuItemSprite *CWaterpump::initMenuItemWithFiles(int type, const char *normal, const char *selected, const char *disable, SEL_MenuHandler selector)
{
    CCSprite *pNormal = CCSprite::create(normal);
    CCSprite *pSelected = CCSprite::create(selected);
    CCSprite *pDisable = CCSprite::create(disable);

    CCMenuItemSprite *pItem = CCMenuItemSprite::create(pNormal, pSelected, pDisable, this, selector);
    int cnt = CPlayerAccount::GetAccountInstance()->GetAccountPropsNum(type);
    char szCntStr[8] = {0};
    sprintf(szCntStr, "%d", cnt);
    CCLabelAtlas *pCntFnt = CCLabelAtlas::create(szCntStr, "UI_02_05.png", 48, 57, '0');
    pCntFnt->setAnchorPoint(ccp(1, 0));
    pCntFnt->setPosition(ccp(pItem->getContentSize().width, 0));
    pItem->addChild(pCntFnt, 1, Tag_ItemFnt);
    pItem->setTag(type);
    return pItem;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
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;
	}

}
Exemplo n.º 11
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;
}
Exemplo n.º 12
0
void GameScene::showOverView()
{
    if (m_pOverLayer == NULL)
    {
        m_pOverLayer = LGLayerColor::create(ccc4(0, 0, 0, 0));
        m_pOverLayer->retain();
        m_pOverLayer->setTouchMode(kCCTouchesOneByOne);
        m_pOverLayer->setTouchEnabled(true);
        m_pOverLayer->setZOrder(3);

        CCSprite *pTitle = CCSprite::create("title_over.png");
        pTitle->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.76f));
        m_pOverLayer->addChild(pTitle);

        CCSprite *pBgScore = CCSprite::create("bg_score.png");
        //pBgScore->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.535f));
        pBgScore->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y - pBgScore->getContentSize().height / 2));
        pBgScore->setTag(kTagOverScoreBoard);
        m_pOverLayer->addChild(pBgScore);

        float bgW = pBgScore->getContentSize().width, bgH = pBgScore->getContentSize().height;

        int record = CCUserDefault::sharedUserDefault()->getIntegerForKey("record", 0);
        if (record < m_CurrentScore)
        {
            record = m_CurrentScore;
            CCUserDefault::sharedUserDefault()->setIntegerForKey("record", record);
            NativeBridge::submitScore(record);

            CCSprite *indicatorNew = CCSprite::create("new.png");
            indicatorNew->setPosition(ccp(bgW * (0.5 - 0.2448980f), bgH * (0.5 - 0.08035714f)));
            pBgScore->addChild(indicatorNew);
        }

        CCLabelAtlas *current = CCLabelAtlas::create(CCString::createWithFormat("%d", m_CurrentScore)->getCString(), "fonts/font2.png", 36, 48, '0');
        current->setAnchorPoint(ccp(0.5, 0.5));
        current->setPosition(bgW / 2, bgH * 0.6394f);
        pBgScore->addChild(current);
        CCLabelAtlas *best = CCLabelAtlas::create(CCString::createWithFormat("%d", record)->getCString(), "fonts/font2.png", 36, 48, '0');
        best->setAnchorPoint(ccp(0.5, 0.5));
        best->setPosition(bgW / 2, bgH * (0.5 - 0.27679f));
        pBgScore->addChild(best);

        CCMenuItemImage *pRetry = LGMenuItemImage::create("retry.png", NULL, this, menu_selector(GameScene::retryCallback));
        CCMenuItemImage *pMenu = LGMenuItemImage::create("menu.png", NULL, this, menu_selector(GameScene::menuCallback));

        pRetry->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.73333333f, m_VisibleOrigin.y + m_VisibleSize.height * 0.285f));
        pMenu->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.26666667f, pRetry->getPositionY()));

        CCMenu *pCCMenu = CCMenu::create(pRetry, pMenu, NULL);
        pCCMenu->setTag(kTagOverMenu);
        pCCMenu->setAnchorPoint(CCPointZero);
        pCCMenu->setPosition(ccp(0, m_VisibleOrigin.y - (pRetry->getPositionY() - m_VisibleOrigin.y) * 2));
        m_pOverLayer->addChild(pCCMenu);
    }

    m_pOverLayer->getChildByTag(kTagOverScoreBoard)->runAction(CCMoveTo::create(0.5f, ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2, m_VisibleOrigin.y + m_VisibleSize.height * 0.535f)));
    m_pOverLayer->getChildByTag(kTagOverMenu)->runAction(CCMoveTo::create(1.0f, CCPointZero));

    if (m_pOverLayer && m_pOverLayer->getParent() == NULL)
    {
        getParent()->addChild(m_pOverLayer);
        CC_SAFE_RELEASE_NULL(m_CurrentLayer);
        m_CurrentLayer = m_pOverLayer;
        m_CurrentLayer->retain();
        onShowOverlay(true);
    }

    m_ScoreLabel->setVisible(false);
}
CCNode* DamageValueEffect::CreateCritDamageLable(unsigned int damage,CCPoint parentPos,bool isHarmFul)
{
	CCPoint uiPos = parentPos;
	CCSprite* critNode = CCSprite::create();
	critNode->setPosition(ccp(uiPos.x,uiPos.y));
	critNode->setAnchorPoint(ccp(0.5,0.5));

	ASprite *as = AspriteManager::getInstance()->getAsprite("UI/ui_inbattle.bin"); 
	CCPoint pt;
	int iFrameID = TXGUI::getResourceIDByName("map_ui_inbattle_FRAME_CRITICALBACK");
	CCSprite* critSprite = as->getSpriteFromFrame_Middle(iFrameID,0,pt);
	if(critSprite)
	{
		critSprite->setPosition(CCPointZero);
		critNode->addChild(critSprite,0);
	}

	char damageString[10];
	sprintf(damageString,"%d",damage);
	CCLabelAtlas* label;
	if(isHarmFul)
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_2.png",43,54,48);
	}
	else
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_3.png",41,43,48);
	}

	if(label)
	{
		label->setAnchorPoint(ccp(0.5f,0.5f));
		label->setPosition(CCPointZero);
		critNode->addChild(label,1);
		if(critSprite)
		{
			float scale_x = label->getContentSize().width / (0.8f * critSprite->getContentSize().width);
			float scale_y = label->getContentSize().height / (0.8f * critSprite->getContentSize().height);
			float scale = (scale_x > scale_y) ? scale_x : scale_y; 
			critSprite->setScale(scale);
			critSprite->setPosition(CCPointZero);
			critSprite->setAnchorPoint(ccp(0.5f,0.5f));
		}
	}

	critNode->setScale(0);
	critNode->runAction(getBattleUIAction());
	if(m_pDamageLabels->find(critNode) == m_pDamageLabels->end())
	{
		m_pDamageLabels->insert(make_pair(critNode,1.3f));
		//this->addChild(critNode);
		if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL
			&& GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer())
		{
			GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(critNode,MAP_Z_OBJ_TOP);
		}
	}

	/*if(isHarmFul)
	{
		HandleCritBurst(uiPos,0);
	}*/

	return critNode;
}
Exemplo n.º 14
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);
}