本文整理汇总了C++中CCNode::convertTouchToNodeSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::convertTouchToNodeSpace方法的具体用法?C++ CCNode::convertTouchToNodeSpace怎么用?C++ CCNode::convertTouchToNodeSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::convertTouchToNodeSpace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchMoved
void PlayerSprite::ccTouchMoved( CCTouch *pTouch, CCEvent *pEvent )
{
if (!m_bIsTouch) return;
CCNode* parent = getParent();
if (parent)
{
setPosition(parent->convertTouchToNodeSpace(pTouch));
}
}
示例2: ccTouchEnded
void LayerMenu::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
if (isClick(pTouch))
{
CCNode* node = _view->getContainer();
CCPoint ptInNode = node->convertTouchToNodeSpace(pTouch);
for (int i = 0; i < 8; ++i)
{
CCSprite* sprite = (CCSprite*)node->getChildByTag(1000 + i);
if (sprite->boundingBox().containsPoint(ptInNode))
{
//进入游戏场景
CCDirector::sharedDirector()->replaceScene(Common::scene(LayerGame::create(i)));
break;
}
}
}
}
示例3: MyTouchDispatcher
void ScutCxListItem::MyTouchDispatcher(CCNode* pParent, int nToutchEvent, CCTouch* touch, CCEvent* event)
{
CCNode* parent = pParent;
while(parent)
{
//对嵌套列表TOUCH END 做事件传递
//if (parent->getClassType() == ScutLIST_classID && nToutchEvent == TOUCHEND)
// break;
if(findInDeque(pParent))
{
if(nToutchEvent == TOUCHEND)
break;
}
CCPoint pos_parent = parent->getPosition();
CCPoint pos_in_parent = parent->convertTouchToNodeSpace(touch);
CCSize size_parent = parent->getContentSize();
////对横屏例表作特殊处理
if(pos_parent.x < 0)
pos_in_parent.x = pos_in_parent.x + pos_parent.x;
CCRect r;
r.origin = CCPointZero;
r.size = size_parent;
if (!r.containsPoint(pos_in_parent))
{
if(pos_parent.y > 0)
{
//对竖屏例表作特殊处理
pos_in_parent.y = pos_in_parent.y + pos_parent.y;
if (!r.containsPoint(pos_in_parent))
{
return;
}
}
else
{
return;
}
}
parent = parent->getParent();
}
switch(nToutchEvent)
{
case TOUCHBEGIN:
{
if(dynamic_cast<CCLayer*>(pParent) != NULL)
{
bool bCatch = ((CCLayer*)pParent)->ccTouchBegan(touch,event);
if(bCatch && findInTouchEventLayerDeque(pParent) )
{
m_pVectorTouchBegan.push_back((CCLayer*)pParent);
m_bCatchEndNode = true;
g_bCatchLayer = true;
}
}
if (pParent && pParent->getChildren())
{
CCNode* pItem = NULL;
for (int i = 0, l = pParent->getChildren()->count(); i < l; ++i)
{
pItem = (CCNode *)pParent->getChildren()->objectAtIndex(i);
if(pItem)
{
MyTouchDispatcher(pItem, nToutchEvent,touch,event);
}
}
}
}
break;
case TOUCHEND:
{
if(dynamic_cast<CCLayer*>(pParent) != NULL)
((CCLayer*)pParent)->ccTouchEnded(touch,event);
if (pParent && pParent->getChildren())
{
CCNode* pItem = NULL;
for (int i = 0, l = pParent->getChildren()->count(); i < l; ++i)
{
pItem = (CCNode *)pParent->getChildren()->objectAtIndex(i);
if(pItem)
{
MyTouchDispatcher(pItem, nToutchEvent,touch,event);
}
}
}
//.........这里部分代码省略.........