当前位置: 首页>>代码示例>>C++>>正文


C++ CCNode::getPositionX方法代码示例

本文整理汇总了C++中CCNode::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getPositionX方法的具体用法?C++ CCNode::getPositionX怎么用?C++ CCNode::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCNode的用法示例。


在下文中一共展示了CCNode::getPositionX方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Attack

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));
	
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例2: initFire

void CSmeltArmor::initFire()
{
	//获取参考位置
	CCNode* pNode = (CCNode*)m_ui->findWidgetById("fire_circle");
	CCPoint pPos = ccp(pNode->getPositionX()+15, pNode->getPositionY()+75);

	if(m_pFire1 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9010");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire1 = CCSprite::create("skill/9010.png");
		m_pFire1->setPosition(pPos);
		m_pFire1->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire1->setVisible(false);
		m_pFire1->setScale(1.6f);
		pNode->getParent()->addChild(m_pFire1, pNode->getZOrder());
	}
	if(m_pFire2 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9011");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire2 = CCSprite::create("skill/9011.png");
		m_pFire2->setPosition(pPos);
		m_pFire2->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire2->setVisible(false);
		m_pFire2->setScale(1.5f);
		pNode->getParent()->addChild(m_pFire2, pNode->getZOrder());
	}
}
开发者ID:54993306,项目名称:Classes,代码行数:29,代码来源:SmeltArmor.cpp

示例3: visit

void CCBClippingNode::visit(){
    
    CCNode* hock = this->getChildByTag(htag);
    if (hock==NULL) {
        getStencil()->setPosition(0, 0);
        getStencil()->setScaleX(1);
        getStencil()->setScaleY(1);
        getStencil()->setRotationX(0);
        getStencil()->setRotationY(0);
        getStencil()->setSkewX(0);
        getStencil()->setSkewY(0);
        getStencil()->setAnchorPoint(ccp(0.5, 0.5));
    }else{
        getStencil()->setPosition(hock->getPositionX(),hock->getPositionY());
        getStencil()->setScaleX(hock->getScaleX());
        getStencil()->setScaleY(hock->getScaleY());
        getStencil()->setRotationX(hock->getRotationX());
        getStencil()->setRotationY(hock->getRotationY());
        getStencil()->setSkewX(hock->getSkewX());
        getStencil()->setSkewY(hock->getSkewY());
        getStencil()->setAnchorPoint(hock->getAnchorPoint());
    }
    
    CCClippingNode::visit();
}
开发者ID:royhu,项目名称:CCBReader-X,代码行数:25,代码来源:CCBClippingNode.cpp

示例4: detect

bool NodeInRect::detect()
{
	CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
	if (pNode != NULL && abs(pNode->getPositionX() - _origin.x) <= _size.width && abs(pNode->getPositionY() - _origin.y) <= _size.height)
	{
		return true;
	}
    return false;
}
开发者ID:pipu,项目名称:CocoStudioConnector,代码行数:9,代码来源:cons.cpp

示例5: runMoveAction

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();
} 
开发者ID:54993306,项目名称:Classes,代码行数:18,代码来源:mainCityUI.cpp

示例6: setBall

void GameScene::setBall() {
	//ボールをバー上に配置する
	if (m_balls->count() <= 0) {
		return;
	}
	BallSprite* ball = dynamic_cast<BallSprite*>(m_balls->objectAtIndex(0));
	CCNode *bar = this->getChildByTag(kTagBar);
//	CCRect rect = bar->boundingBox();
	ball->setPosition(
			ccp(bar->getPositionX(), bar->getPositionY() + bar->getContentSize().height + 10));
//    CCLOG("# setBall #bar.width: %f, height: %f",
//          bar->getContentSize().width, bar->getContentSize().height);
//    CCLOG("# setBall #bar position X: %f, Y: %f",
//          bar->getPositionX(), bar->getPositionY());
//	ball->setPosition(
//			ccp(bar->getPositionX() + bar->getContentSize().width / 2, bar->getPositionY() + bar->getContentSize().height));
	this->addChild(ball);

	m_balls->removeObjectAtIndex(0);
	m_activeballs->addObject(ball);
}
开发者ID:sakurabird,项目名称:cocos2dx-BlockShooting,代码行数:21,代码来源:GameScene.cpp

示例7:

void E002_C010_P230::_setPositionOutParent(CCNode* child, CCNode* newParent)
{
    CCNode* parent = (CCNode*)child->getParent();
    if (parent && child) {
    
        child->retain();
        
        CCSize parentSize = parent->getContentSize();
        CCPoint parentAnchor = parent->getAnchorPoint();
        
        float posX =  parent->getPositionX() - parentSize.width*parentAnchor.x + child->getPositionX();
        float posY =  parent->getPositionY() - parentSize.height*parentAnchor.y + child->getPositionY();
    
        child->removeFromParentAndCleanup(false);
        child->setPosition(ccp(posX, posY));
        this->addChild(child);
        
        child->release();
    }
    
}
开发者ID:JeonJonguk,项目名称:e002_c010,代码行数:21,代码来源:E002_C010_P230.cpp

示例8: InitBG


//.........这里部分代码省略.........
                        new_rand = RandomInt(1, 7);
                        for(int j=0; j < poster_rand.size(); j++){
                            int val = poster_rand[j];
                            if(val == new_rand){
                                found = true;
                                break;
                            }
                        }
                    }while(found);
                    poster_rand.push_back(new_rand);
                }else{
                    poster_rand.push_back(RandomInt(1, 7));
                }
                last = 0;
                sprintf(name,"ctm_SpacePoster_%02d.png",poster_rand.back());
                sprite = CCSprite::createWithSpriteFrameName(name);
                sprite->setScale(scale);
                m_Parallax2Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i-192.0f, 103.0f);
                pNode->addChild(sprite,2,CCPointMake(0.90f,0.0f),m_Parallax2Points[i]);
                m_Parallax2->addObject(sprite);
            }
            else
            {
                last = 1;
                if(retro_rand.size()>0){
                    int new_rand;
                    bool found = false;
                    do{
                        found = false;
                        new_rand = RandomInt(1, 6);
                        for(int j=0; j < retro_rand.size(); j++){
                            int val = retro_rand[j];
                            if(val == new_rand){
                                found = true;
                                break;
                            }
                        }
                    }while(found);
                    retro_rand.push_back(new_rand);
                }else{
                    retro_rand.push_back(RandomInt(1, 6));
                }
                sprintf(name,"ctm_space_Retro%02d.png",(RandomInt(1, 6)));
                CCNode *object = getBGObject();
                m_Parallax2Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i-128.0f+object->getPositionX(), 103.0f+object->getPositionY());
                pNode->addChild(object,object->getZOrder(),CCPointMake(0.90f,0.0f),m_Parallax2Points[i]);
                m_Parallax2->addObject(object);
            }
            
            //torch
            CCNode *object = getBGObject();
            m_Parallax3Points[i] = ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i+object->getPositionX(), 103.0f+object->getPositionY());
            pNode->addChild(object,object->getZOrder(),CCPointMake(0.90f,0.0f),m_Parallax3Points[i]);
            m_Parallax3->addObject(object);
        }
        
    }
    else
    {
        m_Parallax2 = NULL;
    }
    
    
    
    m_Track = CCArray::createWithCapacity(4);
    m_Track->retain();
    for(int i = 0; i < 4; i++)
    {
        int r = 2.999f * CCRANDOM_0_1();
        switch(r){
            default:
            case 0:
                sprite = CCSprite::create("Space_Panels_01.png");
                break;
            case 1:
                sprite = CCSprite::create("Space_Panels_02.png");
                break;
            case 2:
                sprite = CCSprite::create("Space_Panels_03.png");
                break;
        }
        sprite->setScaleX(scaleX);
        sprite->setScaleY(scaleY);
        m_TrackPoints[i] = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_BOTTOM_LEFT);
        m_TrackPoints[i].x += (256.0f*i)*scaleX;
        m_TrackPoints[i].y += -28.0f*scale;
        sprite->setPosition(m_TrackPoints[i]);
        m_layer->addChild(sprite,4);
        m_Track->addObject(sprite);
        
        /*       sprite = CCSprite::create("ctm_256_Front_hazardstripe.png");
         sprite->setScaleX(scaleX);
         sprite->setScaleY(scaleY);
         sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_BOTTOM_LEFT, 256.0f*i, 55.0f));
         addChild(sprite,4);
         */
    }
    
    
}
开发者ID:ryanmcbride,项目名称:CrashTestMonkeys,代码行数:101,代码来源:SpaceBackGround.cpp


注:本文中的CCNode::getPositionX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。