Example #1
0
void GamePan::Attack(int direct)
{
	CCNode* fieldNode = m_pCcbNode->getChildByTag(kTagGamePanField);
	for(int i =0;i<fieldNode->getChildrenCount();i++)
	{
		fieldNode->getChildByTag(i);
	}
	
	std::string pinyinStr = Utils::getPinyinStr(answer);//GET_STRING(TEXT_JUQING_SPLASH_BEGIN2);
	std::string answerPinyin = Utils::getPinyinLetter(pinyinStr);
	vector<string> answerArr = Utils::split(answerPinyin);
	vector<string> pinyinArr = Utils::split(_pinyinStr);
	for(int i =0;i<pinyinArr.size();i++)
	{
		string letter = pinyinArr.at(i);
		int pos = -1;
		for(int j =0;j<answerArr.size();j++)
		{
			string tmp = answerArr.at(j);
			if(tmp.compare(letter) == 0)
			{
				pos = i;
			}
		}
		if(i>0 && pos>0)
		{
			CCNode* bar = fieldNode->getChildByTag(i);
			CCMoveTo* moveTo = NULL;
			switch (direct)
			{
			case NPC_ATTACK:
				{
					moveTo = CCMoveTo::create(0.3f,ccp(bar->getPositionX(),bar->getPositionY()-MOVE_STEP));
				}
				break;
			case PLAYER_ATTACK:
				{
					moveTo = CCMoveTo::create(0.3f,ccp(bar->getPositionX(),bar->getPositionY()+MOVE_STEP));
				}
				break;
			}
			bool isMoveAble = true;
			float dis = bar->getPositionY();
			if(dis>=MAX_DISTANCE)
			{
				isMoveAble = false;
			}
			else if(dis<= -MAX_DISTANCE)
			{
				isMoveAble = false;
			}
			if(isMoveAble)
			{
				bar->runAction(moveTo);
			}
		}
	}
	this->runAction(CCSequence::create(CCDelayTime::create(0.35f),CCCallFunc::create(this,callfunc_selector(GamePan::checkWhoWin)),NULL));
	
}
Example #2
0
void CMainCityUI::runMovePreAction(int tag)
{
	CCNode *sBtn = dynamic_cast<CCNode*>( m_ui->getChildByTag(tag));
	sBtn->setVisible(true);

	CCArray *children = sBtn->getChildren();
	for (int i = 0; i < sBtn->getChildrenCount(); i++)
	{	
		CCNode *child = (CCNode*)children->objectAtIndex(i);
		CCMoveBy *move = CCMoveBy::create(0.3f,ccp(-m_moveX[tag-1],0));
		child->runAction(move);
		child->setAnchorPoint(CCPointCenter);
		child->setVisible(true);
	}
}
Example #3
0
void CMainCityUI::runMoveAction(int fromTag, int toTag,float moveTime)
{
	CCNode *sBtn =  m_ui->getChildByTag(fromTag);
	CButton *dBtn = dynamic_cast<CButton*>( m_ui->getChildByTag(toTag));

	CCArray *children = sBtn->getChildren();

	CCNode *child = nullptr;
	for (int i = 0; i < sBtn->getChildrenCount(); i++)
	{	
		child = (CCNode*)children->objectAtIndex(i);
		CCMoveBy *move = CCMoveBy::create(moveTime,ccp(dBtn->getPositionX() -child->getPositionX(),0));
		CCCallFuncN *hideCall = CCCallFuncN::create(this,callfuncN_selector(CMainCityUI::hideBtn));
		CCSequence *ccseque = CCSequence::create(move,hideCall,nullptr);
		child->runAction(ccseque);
	}
	m_moveX[fromTag-1] = dBtn->getPositionX() - child->getPositionX();
} 
Example #4
0
void GUIBase::resetPriority(CCNode* pNode, int priority)
{
	CCArray* pChildren = pNode->getChildren();

	CCObject* pObj = NULL;
	CCARRAY_FOREACH(pChildren, pObj)
	{
		CCNode* pChild = (CCNode*)pObj;
		if (pChild->getChildrenCount() > 0)
		{
			resetPriority(pChild, priority);
		}

		// CCMenu
		CCMenu* pMenu = dynamic_cast<CCMenu*>(pChild);
		if (pMenu)
		{
			pMenu->setTouchPriority(priority  - 1);
			continue;
		}

		// CCScrollView
		CCScrollView* pCCScrollView = dynamic_cast<CCScrollView*>(pChild);
		if (pCCScrollView)
		{
			pCCScrollView->setTouchPriority(priority  - 1);
			continue;
		}

		// CCControlButton
		CCControlButton* pCCControlButton = dynamic_cast<CCControlButton*>(pChild);
		if (pCCControlButton)
		{
			pCCControlButton->setTouchPriority(priority  - 1);
			continue;
		}
	}
Example #5
0
bool ActivityView::init()
{
    if (!PopupBaseView::init()) {
        return false;
    }
    setIsHDPanel(true);
    if (m_obj->type != 6) return false;
    CCLoadSprite::doResourceByCommonIndex(500, true);
    CCLoadSprite::doResourceByCommonIndex(502, true);
    CCLoadSprite::doResourceByCommonIndex(506, true);
    auto size = CCDirector::sharedDirector()->getWinSize();
    this->setContentSize(CCSize(640, 852));
    if (CCCommonUtils::isIosAndroidPad())
    {
        this->setContentSize(CCSize(1536, 2048));
    }
    CCBLoadFile("ActivityView", this, this);
    if (CCCommonUtils::isIosAndroidPad()) {
        m_bottomNode->setPositionY(m_bottomNode->getPositionY() - (size.height - 2048));
        m_listNode->setPositionY(m_listNode->getPositionY() - (size.height - 2048));
        m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + size.height - 2048));
    } else {
        m_bottomNode->setPositionY(m_bottomNode->getPositionY() - (size.height - 852));
        m_listNode->setPositionY(m_listNode->getPositionY() - (size.height - 852));
        m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + size.height - 852));
    }

    if (m_obj->exchange == "1" || m_obj->exchange == "2") {
        m_bottomNode->setVisible(true);
    } else {
        m_bottomNode->setVisible(false);
        if (CCCommonUtils::isIosAndroidPad())
        {
            m_listNode->setPositionY(m_listNode->getPositionY() - 178);
            m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + 178));
        } else {
            m_listNode->setPositionY(m_listNode->getPositionY() - 92);
            m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + 92));
        }
    }
    m_titleLabel->setString(_lang("150215"));
    CCCommonUtils::setButtonTitle(m_rwdBtn, _lang("133076").c_str());
    Node* node = Node::create();
    CCLabelIF* label = nullptr;
    Sprite* spr = nullptr;
    float height = 0;
    {
        if (!m_obj->rewardIds.empty()) {
            if (m_obj->showDialogs.size() > 0) {
                height -= 20;
                if (CCCommonUtils::isIosAndroidPad())
                {
                    height -= 20;
                }
            }
            for (auto it = m_obj->showDialogs.begin(); it != m_obj->showDialogs.end(); ++it) {
                vector<string> tVec;
                CCCommonUtils::splitString(*it, ";", tVec);
                string showStr("");
                if (tVec.size() == 1)
                {
                    showStr = _lang(tVec[0]);
                } else if (tVec.size() == 2) {
                    showStr = _lang_1(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str());
                } else if (tVec.size() == 3) {
                    showStr = _lang_2(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str(), (CCCommonUtils::getNameById(tVec[2])).c_str());
                } else if (tVec.size() == 4) {
                    showStr = _lang_3(tVec[0].c_str(), (CCCommonUtils::getNameById(tVec[1])).c_str(), (CCCommonUtils::getNameById(tVec[2])).c_str(), (CCCommonUtils::getNameById(tVec[3])).c_str());
                }
                label = CCLabelIF::create(showStr.c_str());
                label->setFontSize(20);
                if (CCCommonUtils::isIosAndroidPad())
                {
                    label->setFontSize(40);
                }
                label->setColor(ccBLACK);
                label->setAnchorPoint(Vec2(0.5, 1));
                label->setDimensions(Size(580, 0));
                if (CCCommonUtils::isIosAndroidPad())
                {
                    label->setDimensions(Size(1300, 0));
                }
                label->setHorizontalAlignment(TextHAlignment::CENTER);
                label->setVerticalAlignment(TextVAlignment::TOP);
                label->setPosition(Vec2(0, height));
                node->addChild(label);
                height -= label->getContentSize().height * label->getOriginScaleY();
            }
            height -= 5;
            if (CCCommonUtils::isIosAndroidPad())
            {
                height -= 5;
            }
            //有几率获得
            label = CCLabelIF::create(_lang("150217").c_str());
            label->setFontSize(18);
            if (CCCommonUtils::isIosAndroidPad())
            {
                label->setFontSize(36);
            }
            label->setAnchorPoint(Vec2(0.5, 1));
            label->setPosition(Vec2(0, height));
            label->setColor({139, 29, 20});
            label->setHorizontalAlignment(TextHAlignment::CENTER);
            label->setVerticalAlignment(TextVAlignment::TOP);
            node->addChild(label);
            height -= label->getContentSize().height * label->getOriginScaleY();
            
            //展示奖励
            int cnt = m_obj->rewardIds.size();
            int hang = ceil(cnt / 6.0);
            for (int i = 1; i <= hang; ++i) {
                if (i < hang) {
                    for (int j = 1; j <= 6; ++j) {
                        ActivityRwdShowCell* cell = ActivityRwdShowCell::create(m_obj->rewardIds.at(j - 1 + (i - 1) * 6));
                        cell->setPositionX(- 80 * 6 / 2 + 80 / 2 + (j - 1) * 80);
                        cell->setPositionY(height - 40);
                        if (CCCommonUtils::isIosAndroidPad()) {
                            cell->setPositionX(- 160 * 6 / 2 + 160 / 2 + (j - 1) * 160);
                            cell->setPositionY(height - 80);
                        }
                        node->addChild(cell);
                    }
                    height -= 80;
                    if (CCCommonUtils::isIosAndroidPad())
                    {
                        height -= 80;
                    }
                } else {
                    int leftCnt = cnt - (i - 1) * 6;
                    for (int j = 1; j <= leftCnt; ++j) {
                        ActivityRwdShowCell* cell = ActivityRwdShowCell::create(m_obj->rewardIds.at((i - 1) * 6 + j - 1));
                        cell->setPositionX(- (80 * leftCnt) / 2 + 80 / 2 + (j - 1) * 80);
                        cell->setPositionY(height - 40);
                        if (CCCommonUtils::isIosAndroidPad()) {
                            cell->setPositionX(- 160 * leftCnt / 2 + 160 / 2 + (j - 1) * 160);
                            cell->setPositionY(height - 80);
                        }
                        node->addChild(cell);
                    }
                    height -= 80;
                    if (CCCommonUtils::isIosAndroidPad())
                    {
                        height -= 80;
                    }
                }
            }
            //空
            height -= 10;
            if (CCCommonUtils::isIosAndroidPad()) {
                height -= 10;
            }
            //横线
            spr = CCLoadSprite::createSprite("Items_tips3_lottery.png");
            spr->setAnchorPoint(Vec2(0.5, 0.5));
            spr->setPosition(0, height);
            node->addChild(spr);
            if (CCCommonUtils::isIosAndroidPad())
            {
                spr->setScale(2);
            }
            //空
            height -= 10;
            if (CCCommonUtils::isIosAndroidPad()) {
                height -= 10;
            }
            //剧情简介
            label = CCLabelIF::create(_lang("150216").c_str());
            label->setAnchorPoint(Vec2(0.5, 1));
            label->setColor(ccBLACK);
            label->setFontSize(20);
            if (CCCommonUtils::isIosAndroidPad()) {
                label->setFontSize(40);
            }
            label->setPosition(0, height);
            label->setHorizontalAlignment(TextHAlignment::CENTER);
            label->setVerticalAlignment(TextVAlignment::TOP);
            node->addChild(label);
            height -= label->getContentSize().height * label->getOriginScaleY();
            //空
            height -= 10;
            if (CCCommonUtils::isIosAndroidPad()) {
                height -= 10;
            }
        }
        //正文
        string mStory = _lang(m_obj->story);
        mStory.append("\n\n\n");
        label = CCLabelIF::create(mStory.c_str());
        label->setFontSize(20);
        if (CCCommonUtils::isIosAndroidPad()) {
            label->setFontSize(40);
        }
        label->setDimensions(Size(580, 0));
        if (CCCommonUtils::isIosAndroidPad()) {
            label->setDimensions(Size(1300, 0));
        }
        label->setAnchorPoint(Vec2(0.5, 1));
        label->setColor({85, 62, 31});
        label->setPosition(0, height);
        label->setHorizontalAlignment(TextHAlignment::CENTER);
        label->setVerticalAlignment(TextVAlignment::TOP);
        node->addChild(label);
        height -= label->getContentSize().height * label->getOriginScaleY();
    }
    ScrollView* view = ScrollView::create(m_listNode->getContentSize());
    if (abs(height) < m_listNode->getContentSize().height) {
        node->setPositionY(m_listNode->getContentSize().height / 2.0 + abs(height) / 2.0);
        height = -m_listNode->getContentSize().height;
    } else {
        node->setPositionY(abs(height));
    }
    view->setContentSize(Size(m_listNode->getContentSize().width, abs(height)));
    view->addChild(node);
    node->setPositionX(view->getContentSize().width / 2);
//    node->setPositionY(abs(height));
    view->setContentOffset(Vec2(0, m_listNode->getContentSize().height - view->getContentSize().height));
    view->setDirection(ScrollView::Direction::VERTICAL);
    m_listNode->addChild(view);
    view->setDelegate(this);
    
    bool st = false;
    if (LuaController::getInstance()->checkActLuaValid(m_obj))
    {
        CCNode* node = LuaController::getInstance()->createActivityAdCell(m_obj);
        if (node && node->getChildrenCount()) {
            m_picNode->addChild(node);
            if (CCCommonUtils::isIosAndroidPad())
            {
                float w = (1536.0 - 1156.0) / 2.0;
                float h = 645;
                node->setContentSize(CCSize(0, 0));
                node->setScaleX(1156.0 / 640.0);
                node->setScaleY(645.0 / 357.0);
                auto layer1 = CCModelLayerColor::create();
                layer1->setAnchorPoint(ccp(0, 0));
                layer1->setContentSize(CCSize(w, h));
                layer1->setPosition(-w, 0);
                layer1->setOpacity(255);
                layer1->setColor(ccBLACK);
//                layer1->setTouchPriority(-999);
                m_picNode->addChild(layer1);
                
                layer1 = CCModelLayerColor::create();
                layer1->setAnchorPoint(CCPointZero);
                layer1->setPosition(ccp(1156, 0));
                layer1->setContentSize(CCSize(w, h));
                layer1->setOpacity(255);
                layer1->setColor(ccBLACK);
//                layer1->setTouchPriority(-999);
                m_picNode->addChild(layer1);
            }
        } else {
            st = true;
        }
    }
    else
    {
        st = true;
    }
    
    if (st) {
        auto nameTTF = CCLabelIF::create(m_obj->name.c_str());
        auto infoTTF = CCLabelIF::create(m_obj->desc.c_str());
        auto bgImg = CCLoadSprite::createSprite("activity_ad_beiyong.png");
        
        nameTTF->setPosition(ccp(16,245));
        nameTTF->setAnchorPoint(ccp(0, 1));
        nameTTF->setFontSize(36);
        nameTTF->setColor({255,219,117});
        nameTTF->setHorizontalAlignment(kCCTextAlignmentLeft);
        nameTTF->setVerticalAlignment(kCCVerticalTextAlignmentTop);
        nameTTF->setDimensions(CCSize(0, 0));
        
        infoTTF->setPosition(ccp(16,201));
        infoTTF->setAnchorPoint(ccp(0, 1));
        infoTTF->setColor({0, 249, 0});
        infoTTF->setHorizontalAlignment(kCCTextAlignmentLeft);
        infoTTF->setVerticalAlignment(kCCVerticalTextAlignmentTop);
        infoTTF->setDimensions(CCSize(300, 0));
        
        
        bgImg->setAnchorPoint(ccp(0, 0));
        bgImg->setPosition(ccp(0, 0));
        auto node = CCNode::create();
        node->addChild(bgImg);
        node->addChild(nameTTF);
        node->addChild(infoTTF);
        m_picNode->addChild(node);
        if (CCCommonUtils::isIosAndroidPad()) {
            float w = (1536.0 - 1156.0) / 2.0;
            float h = 645;
            node->setContentSize(CCSize(0, 0));
            node->setScaleX(1156.0 / 640.0);
            node->setScaleY(645.0 / 357.0);
            auto layer1 = CCModelLayerColor::create();
            layer1->setAnchorPoint(ccp(0, 0));
            layer1->setContentSize(CCSize(w, h));
            layer1->setPosition(-w, 0);
            layer1->setOpacity(255);
            layer1->setColor(ccBLACK);
            //                layer1->setTouchPriority(-999);
            m_picNode->addChild(layer1);
            
            layer1 = CCModelLayerColor::create();
            layer1->setAnchorPoint(CCPointZero);
            layer1->setPosition(ccp(1156, 0));
            layer1->setContentSize(CCSize(w, h));
            layer1->setOpacity(255);
            layer1->setColor(ccBLACK);
            //                layer1->setTouchPriority(-999);
            m_picNode->addChild(layer1);
        }
    }
    
    if (m_obj->exchange == "2") {
        if (ActivityController::getInstance()->m_exc2Data.find(m_obj->id) == ActivityController::getInstance()->m_exc2Data.end()) {
            ActivityController::getInstance()->startGetAct6Data();
        } else {
            if (!ActivityController::getInstance()->checkIsToday(ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refreshTime)) {
                ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refreshTime = GlobalData::shared()->getTimeStamp();
                ActivityController::getInstance()->m_exc2RefInfo[m_obj->id].m_refresh = 0;
            }
        }
    } else if (m_obj->exchange == "1") {
        if (!ActivityController::getInstance()->isAct1DataInit(m_obj->id)) {
            ActivityController::getInstance()->startGetAct6Data();
        } else {
            ActivityController::getInstance()->checkAct1ReFreshTimes(m_obj->id);
//            if (ActivityController::getInstance()->isAct1DataShouldRefresh(m_obj->id))
//            {
//                ActivityController::getInstance()->startAct6Refresh(m_obj->id);
//            }
        }
    }

    return true;
}