本文整理汇总了C++中CCTMXTiledMap::convertToNodeSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTMXTiledMap::convertToNodeSpace方法的具体用法?C++ CCTMXTiledMap::convertToNodeSpace怎么用?C++ CCTMXTiledMap::convertToNodeSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTMXTiledMap
的用法示例。
在下文中一共展示了CCTMXTiledMap::convertToNodeSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchEnded
void RPGMapSceneLayer::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
if(this->m_touchedDialogNPC)
{
CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
CCPoint point = touch->getLocation();
point = bgMap->convertToNodeSpace(point);
if(this->m_touchedDialogNPC->boundingBox().containsPoint(point))
{
this->m_touchedDialogNPC->stopAutoMove(); //暂时停止自动移动
this->enabledControl(false);
string content = this->m_touchedDialogNPC->m_content->getCString();
RPGMapDialogLayer *dialogLayer = RPGMapDialogLayer::create(this->m_stringList, &this->m_db, this->m_touchedDialogNPC);
this->addChild(dialogLayer);
CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu);
mainMenu->setVisible(false);
//player和NPC互相对着
RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer);
switch (this->m_dialogDirection)
{
case kRPGMapSceneLayerDialogDirectionUp:
{
player->setDirection(kRPGMapRoleSpriteDirectionDown);
this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionUp);
}
break;
case kRPGMapSceneLayerDialogDirectionDown:
{
player->setDirection(kRPGMapRoleSpriteDirectionUp);
this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionDown);
}
break;
case kRPGMapSceneLayerDialogDirectionLeft:
{
player->setDirection(kRPGMapRoleSpriteDirectionRight);
this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionLeft);
}
break;
case kRPGMapSceneLayerDialogDirectionRight:
{
player->setDirection(kRPGMapRoleSpriteDirectionLeft);
this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionRight);
}
break;
default:
break;
}
}
}
this->m_touchedDialogNPC = NULL;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionNone;
}
示例2: ccTouchBegan
bool RPGMapSceneLayer::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer);
//循环判断点击了哪一个NPC,如果有点中则m_isTouchedNPC为true
for (int i = 0; i < bgMap->getChildren()->count(); i++)
{
CCObject *item = bgMap->getChildren()->objectAtIndex(i);
if(dynamic_cast<RPGMapRoleSprite*>(item) != NULL)
{
RPGMapNPCRoleSprite *npc = (RPGMapNPCRoleSprite*)item;
if(npc->m_type == kRPGMapRoleSpriteTypeNPC)
{
//判断player是否存在该NPC的四个方向(距离为一格),存在则为true
bool exist = false;
if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(0, GAME_TMX_ROLE_HEIGHT))))
{
//上
exist = true;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionUp;
}
else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(0, -GAME_TMX_ROLE_HEIGHT))))
{
//下
exist = true;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionDown;
}
else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(-GAME_TMX_ROLE_WIDTH, 0))))
{
//左
exist = true;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionLeft;
}
else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(GAME_TMX_ROLE_WIDTH, 0))))
{
//右
exist = true;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionRight;
}
if(exist)
{
CCPoint point = touch->getLocation();
point = bgMap->convertToNodeSpace(point);
if(npc->boundingBox().containsPoint(point))
{
this->m_touchedDialogNPC = npc;
break;
}
}
}
}
}
//如果是点中了NPC则进入ccTouchEnded的处理
if(this->m_touchedDialogNPC)
return true;
else
{
//传入到摇杆的事件处理
CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu);
mainMenu->setVisible(false);
return false;
}
}