本文整理汇总了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));
}
示例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());
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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);
*/
}
}