本文整理汇总了C++中CCNode::convertToNodeSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::convertToNodeSpace方法的具体用法?C++ CCNode::convertToNodeSpace怎么用?C++ CCNode::convertToNodeSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::convertToNodeSpace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateShowArea
void CHandBookPanel::updateShowArea()
{
CCNode* pLayer = m_ui;
if(m_pHeroLayer) m_pHeroLayer->setVisible(false);
if(m_pMonsterLayer) m_pMonsterLayer->setVisible(false);
if(m_pEquipLayer)m_pEquipLayer->setVisible(false);
switch (m_iType)
{
case HandBookTabHero:
{
if(!m_pHeroLayer)
{
m_pHeroLayer = CHandBookHeroLayer::create();
m_pHeroLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pHeroLayer);
m_pHeroLayer->setPosition(pLayer->convertToNodeSpace(m_pHeroLayer->getPosition()));
AskForHandBook(m_iType);
}
else
{
m_pHeroLayer->setVisible(true);
}
}
break;
case HandBookTabMonster:
{
if(!m_pMonsterLayer)
{
m_pMonsterLayer = CHandBookMonsterLayer::create();
m_pMonsterLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pMonsterLayer);
m_pMonsterLayer->setPosition(pLayer->convertToNodeSpace(m_pMonsterLayer->getPosition()));
AskForHandBook(m_iType);
}
m_pMonsterLayer->setVisible(true);
}
break;
case HandBookTabEquip:
{
if(!m_pEquipLayer)
{
m_pEquipLayer = CHandBookEquipLayer::create();
m_pEquipLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pEquipLayer);
m_pEquipLayer->setPosition(pLayer->convertToNodeSpace(m_pEquipLayer->getPosition()));
AskForHandBook(m_iType);
}
m_pEquipLayer->setVisible(true);
}
break;
case HandBookTabMax:
break;
default:
break;
}
}
示例2: ccTouchesBegan
void ScrollViewDemo::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
CCTouch *touch = (CCTouch*)pTouches->anyObject();
CCNode *clipper = this->getChildByTag(kTagClipperNode);
CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
CCRect rect = CCRectMake(0, 0, clipper->getContentSize().width, clipper->getContentSize().height);
m_bScrolling = rect.containsPoint(point);
m_lastPoint = point;
}
示例3: ccTouchesMoved
void ScrollViewDemo::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
if (!m_bScrolling) return;
CCTouch *touch = (CCTouch*)pTouches->anyObject();
CCNode *clipper = this->getChildByTag(kTagClipperNode);
CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
CCPoint diff = ccpSub(point, m_lastPoint);
CCNode *content = clipper->getChildByTag(kTagContentNode);
content->setPosition( ccpAdd(content->getPosition(), diff) );
m_lastPoint = point;
}
示例4: isTouchInside
bool CCtrlPage::isTouchInside( cocos2d::CCTouch * touch )
{
CCNode* pParent = this->getParent();
if (NULL == pParent)
{
return false;
}
CHECKF(touch);
CCPoint touchLocation = touch->getLocation(); // Get the touch position
touchLocation = pParent->convertToNodeSpace(touchLocation);
CCRect bBox=boundingBox();
return bBox.containsPoint(touchLocation);
}
示例5: setWorldPos
void Character::setWorldPos(CCPoint posInWorld)
{
if(m_bodyArray.size() == 0)
return ;
b2Body* pBody = m_bodyArray[0];
if(!pBody)
return;
pBody->SetTransform(b2Vec2(posInWorld.x/PTM_RATIO,posInWorld.y/PTM_RATIO), 0);
CCSprite* pSprite = (CCSprite*)pBody->GetUserData();
if(!pSprite)
return ;
CCNode* pParent =pSprite->getParent();
if(!pParent)
return;
CCPoint point = pParent->convertToNodeSpace(CCPointMake( posInWorld.x/PTM_RATIO,posInWorld.y/PTM_RATIO));
pSprite->setPosition(point);
}
示例6: ccTouchesended
void ConvertToNode::ccTouchesended(CCSet* touches, CCEvent *event)
{
for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
{
CCTouch* touch = (CCTouch*)(*it);
CCPoint location = touch->getLocation();
for( int i = 0; i < 3; i++)
{
CCNode *node = getChildByTag(100+i);
CCPoint p1, p2;
p1 = node->convertToNodeSpaceAR(location);
p2 = node->convertToNodeSpace(location);
CCLOG("AR: x=%.2f, y=%.2f -- Not AR: x=%.2f, y=%.2f", p1.x, p1.y, p2.x, p2.y);
}
}
}