virtual void                                    registerWithTouchDispatcher(void);
virtual bool ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent);
virtual void ccTouchMoved(CCTouch *pTouch,CCEvent *pEvent);
virtual void ccTouchEnded(CCTouch *pTouch,CCEvent *pEvent); virtual void tableCellHighlight(CCTableView* table, CCTableViewCell* cell);
//设置成-1让它的层级降低这样就可以优先被触发
//这样就会先执行touchbegain再执行tableCellHighlight
void CCardlayer::registerWithTouchDispatcher(void)
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -, false);
}
bool CCardlayer::ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent)
{
switch (m_eClickTable)
{
case CCardlayer::CARD_TABLE_EQUIP_TAG:
{
if (m_nClickIndex != )
return false;
}
break;
case CCardlayer::CARD_TABLE_GENERAL_TAG:
{
if (m_nClickIndex != )
return false;
}
break;
case CCardlayer::CARD_TABLE_TRAP_TAG:
{
if (m_nClickIndex != )
return false;
}
break;
default:
break;
} m_pTouchLocation = pTouch; //设置该函数优先触发主要是为了获取到这个变量 return true;
}
void CCardlayer::tableCellHighlight(CCTableView* table, CCTableViewCell* cell)
{
m_tPos = cell->convertTouchToNodeSpace(m_pTouchLocation);
for (int i = ; i < ; ++i)
{
CCSprite* pFrame = (CCSprite*)cell->getChildByTag(CARD_CELL_BTN_LEFT_TAG + i);
CC_ERROR(pFrame, "【CCardlayer::tableCellHighlight】 pFrame 为空");
if(pFrame->boundingBox().containsPoint(m_tPos))
{
UINT unIndex = cell->getIdx();
m_nMoveIdx = unIndex * RIGHT_CELL_BTN_AMOUNT + i;
this->LoadMove();
return;
}
}
}
void CCardlayer::LoadMove()
{
std::string g_ImgPath(CGlobalMgr::GetInstance()->GetResourcesEx());
std::string strPath;
const Item_Info* pInfo = NULL;
const CEudemon* pEudemon = NULL; CCSprite* pImgMove = NULL; switch (m_eClickTable)
{
case CCardlayer::CARD_TABLE_EQUIP_TAG:
{
pInfo = m_pPackageMgr->QueryEquipById(m_nMoveIdx);
CC_ERROR(pInfo, "【CCardlayer::LoadMove】pInfo 为空")
CCString* pStrImgMove = CCString::createWithFormat("%d", pInfo->nImageIdx);
CC_ERROR(pStrImgMove, "【CCardlayer::LoadMove】pStrImgMove 为空")
strPath = g_ImgPath + pStrImgMove->getCString() + ".png";
pImgMove = CCSprite::create(strPath.c_str());
}
break;
case CCardlayer::CARD_TABLE_GENERAL_TAG:
{
pEudemon = m_pCardMgr->QueryEudemonByIndex(m_nMoveIdx);
CC_ERROR(pEudemon, "【CCardlayer::LoadMove】pEudemon 为空")
CCString* pStrImgMove = CCString::createWithFormat("%d", pEudemon->GetLookFace());
CC_ERROR(pStrImgMove, "【CCardlayer::LoadMove】pStrImgMove 为空")
strPath = g_ImgPath + pStrImgMove->getCString() + ".png";
pImgMove = CCSprite::create(strPath.c_str());
}
break;
case CCardlayer::CARD_TABLE_TRAP_TAG:
{
pInfo = m_pPackageMgr->QueryEquipById(m_nMoveIdx);
CCString* pStrImgMove = CCString::createWithFormat("%d", pInfo->nImageIdx);
CC_ERROR(pStrImgMove, "【CCardlayer::LoadMove】pStrImgMove 为空")
strPath = g_ImgPath + pStrImgMove->getCString() + ".png";
pImgMove = CCSprite::create(strPath.c_str());
}
break;
default:
break;
}
CC_ERROR(pImgMove, "【CCardlayer::LoadMove】pImgMove 为空")
pImgMove->setPosition(m_tPos);
pImgMove->setAnchorPoint(ccp(0.5, 0.5));
pImgMove->setVisible(false);
pImgMove->setTag(CARD_IMG_MOVE_TAG);
this->addChild(pImgMove);
}
void CCardlayer::ccTouchMoved(CCTouch *pTouch,CCEvent *pEvent)
{
CCSprite* pImgMove = (CCSprite*)this->getChildByTag(CARD_IMG_MOVE_TAG);
CC_ERROR(pImgMove, "【CCardlayer::ccTouchMoved】pImgMove为空")
pImgMove->setVisible(true);
pImgMove->setPosition(pTouch->getLocation());
} void CCardlayer::ccTouchEnded(CCTouch *pTouch,CCEvent *pEvent)
{
CCPoint tPos = pTouch->getLocation();
if ((tPos.x >= RIGHT_RECT_START_X && tPos.x <= RIGHT_RECT_START_X + RIGHT_RECT_WIDTH)
&& (tPos.y >= RIGHT_RECT_START_Y && tPos.y <= RIGHT_RECT_START_Y + RIGHT_RECT_HEIGH))
{ } this->removeChildByTag(CARD_IMG_MOVE_TAG);
}

最新文章

  1. 【转】ListView学习笔记(二)——ViewHolder
  2. RobotFrameWork webservice soap接口测试 (二)
  3. Maven简介与简单使用
  4. angular-ui-router状态不变刷新页面
  5. Java —— 时区(夏令时)问题
  6. ArcGIS Server 10.2 实战(四)格栅动态配色服务
  7. HAL打开驱动失败
  8. com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException
  9. 转:PHP性能优化大全
  10. fluentd结合kibana、elasticsearch实时搜索分析hadoop集群日志&lt;转&gt;
  11. 密钥登录linux
  12. Filter和FilterChain具体的使用说明
  13. Codeforces548D:Mike and Feet(单调栈)
  14. 纪念一下java学习之第一个get请求。
  15. Mysql 5.1的坑
  16. Java 前后端List传值
  17. 如何在windows上调试安卓机谷歌浏览器上的页面
  18. python 模式之工厂模式
  19. 《FDTD electromagnetic field using MATLAB》读书笔记之 Figure 1.14
  20. Spring Cloud Config 1 (分布式配置中心)

热门文章

  1. Linux软硬连接
  2. EMS_PM_STORAGE
  3. flex水平垂直居中
  4. 解决inline-block上下不对齐
  5. 阿里员工都是这样排查Java问题的,附工具单(转)
  6. fileUpload(草稿)
  7. oracle安装后sqlnet.ora文件
  8. Language and Compiler Features Since Delphi 7
  9. jenkins 图文教程 下载 --》安装--》更改默认端口号,附自启动脚本
  10. 进阶之路(基础篇) - 010 Arduino 函数(基本、串口、SPI)