本文整理汇总了C++中MyMap::collisionDetection方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMap::collisionDetection方法的具体用法?C++ MyMap::collisionDetection怎么用?C++ MyMap::collisionDetection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMap
的用法示例。
在下文中一共展示了MyMap::collisionDetection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchEnded
void MyMenu::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent) {
//先检测路径在~调用回调
if (m_pSelectedItem) {
//TODO
// if (m_pSelectedItem->getTag() == myTiledMenuItemTag)
{
//点击主建筑时
MyMap* myMap = (MyMap*)map;
if (!isActive && isMoved) {
//未激活建筑 同时移动地图时,不激活建筑
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
m_pSelectedItem->unselected();
m_eState = kCCMenuStateWaiting;
} else if(!isActive && !isMoved) {
//未激活建筑时点击建筑时(不移动地图),激活建筑,取消其他建筑
((MyMap*)map)->cancelAllBuilding();
CCMenu::ccTouchEnded(pTouch, pEvent);
} else if(isActive && isMoved) {
//激活建筑并拖动建筑
if (myMap->collisionDetection()) {
//落点有碰撞,播错误提示并取消
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_error.wav");
m_pSelectedItem->unselected();
m_eState = kCCMenuStateWaiting;
} else {
//落点无碰撞,放置建筑
cacheLoc = this->getPosition();
CCPoint loc = getPositionByTiled();
MyMenu::reorderZandTouchPriority(999999-this->getPosition().y, kCCMenuHandlerPriority-loc.x-loc.y);
((MyMap*)map)->dispearTip();
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_place.wav");
CCMenu::ccTouchEnded(pTouch, pEvent);
}
} else if(isActive && !isMoved) {
//建筑激活并且没有移动
if(!myMap->isBuild()) {
//不在建筑模式下,取消选择
if (!((MyMap*)map)->collisionDetection()) {
//没有在碰撞区,成功取消,并设置Y的位置
((MyMap*)map)->cancelAllBuilding();
CCPoint loc = getPositionByTiled();
MyMenu::reorderZandTouchPriority(999999-this->getPosition().y, kCCMenuHandlerPriority-loc.x-loc.y);
} else {
//在碰撞区,播错误声音,不取消
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_error.wav");
}
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
m_pSelectedItem->unselected();
m_eState = kCCMenuStateWaiting;
} else {
//在建筑模式下,
if (!((MyMap*)map)->collisionDetection()) {
//没有在碰撞区
CCPoint loc = getPositionByTiled();
MyMenu::reorderZandTouchPriority(999999-this->getPosition().y, kCCMenuHandlerPriority-loc.x-loc.y);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_place.wav");
CCMenu::ccTouchEnded(pTouch, pEvent);
} else {
//在碰撞区,播错误声音,不取消
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_error.wav");
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
m_pSelectedItem->unselected();
m_eState = kCCMenuStateWaiting;
}
//.........这里部分代码省略.........