从tableview中拖动某个精灵
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);
}
从tableview中拖动某个精灵的更多相关文章
- Tableview中Dynamic Prototypes动态表的使用
Tableview时IOS中应用非常广泛的控件,当需要动态的添加多条不同的数据时,需要用动态表来实现,下面给出一个小例子,适用于不确定Section的数目,并且每个Section中的行数也不同的情况, ...
- 关于tableView中tableHeaderView/tableFooterView/sectionHeader/sectionFooter/contentInset的理解
其实每个人的理解有所不同,找到最有利于自己的理解方式即可.有人把Cell,tableHeaderView,tableFooterView,sectionHeader,sectionFooter这些属性 ...
- ubuntu 工作区中拖动一个窗体到另一个工作区就卡住回不到桌面了
ubuntu 工作区中拖动一个窗体到另一个工作区就卡住回不到桌面了 解决方法: 按 alt + 回车 键直接就返回去了
- TableView 中cell间的分割线(及其他控件间(内)的分割线)设置
知识点: 1.在应用开发中,tableView中自带的分割线满足不了开发需求: 2.一些子空间中添加一些类似于分割线一样的东西等······ 补充知识点:导航条左侧或右侧的控件尽量靠近屏幕边缘设置 需 ...
- 关于TableView中出现deallocated问题
Message sent to deallocated instance 关于的ios 开发中 deallocated问题,相信大家遇到了不少了: 关于怎么查找解决这个问题,特别是当问题在tableV ...
- iOS中关于动态Tableview中的cell数据传输的多线程问题解决之拙见
iOS中关于动态Tableview中的cell数据传输的多线程问题解决之拙见 (2015-12-05 12:48:20)[编辑][删除] 转载▼ 首先我们先明确一下问题: 1.因为UI是在主线 ...
- 在unity中用鼠标实现在场景中拖动物体,用鼠标滚轮实现缩放
在场景中添加一个Plan,Camera,Directional Light,Cube.添加两个脚本scrollerScirpt(挂在Camera),CubeDragScript(挂在Cube上). 1 ...
- 如何在Cocos2D 1.0 中掩饰一个精灵(一)
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 原帖来自Ray Wunderlich写的精彩的文章 How To ...
- tableview中头部信息
//创建tableview中头部的文件#define kPadding 10 #define kIconWidth 100 #define kIconHeight 100 #define kCount ...
随机推荐
- 在QTableView中某列中添加Button的导致滚动条滚动的时候消失的问题
之前在项目上需要在表格中加入Button是按照以下两个文章的做法: http://www.cnblogs.com/li-peng/p/3961843.html http://www.cnblogs.c ...
- STAF进行分布式脚本分发----实践篇
该博文理论支持文章:http://www.cnblogs.com/zhangfei/p/3169139.html 一.准备条件 1.安装STAF.由于其官网被墙了,所以大家可进入WAT群的网盘里去下载 ...
- CMFCPropertyGridProperty用法
MFCPropertyGridCtrl 是VC 2008 pack中的控件类. CMFCPropertyGridProperty这个控件类中的属性值类类. 针对修改属性后,对属性值改变的消息处理: 方 ...
- Android tesseract-orc之扫描身份证号码
踩了不少坑,终于把这个扫描版的身份证识别做出来了,图片识别引擎用的是tesseract,在已经训练好样本的情况下,感觉识别率还是一般般~ 下面说一说大概几个坑. 一. 编译tesseract-orc ...
- Tomcat7并发和线程数
最近一直在解决线上一个问题,表现是: Tomcat每到凌晨会有一个高峰,峰值的并发达到了3000以上,最后的结果是Tomcat线程池满了,日志看很多请求超过了1s. 服务器性能很好,Tomcat版本是 ...
- C# 两个时间相减 返回 对应天时分秒
"; //string sdsdsdsds = "1"; , '); //不足2位 就补充0 足2位 就不变 DateTime dts1 = DateTime.Now; ...
- php非阻塞服务器
<?php class PHPSocketServer { const ERROR = 0; const LOG = 1; const DEBUG = 2; private $aConfig = ...
- MongoDB 学习笔记(8)---$type 操作符
$type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 类型 数字 备注 Double 1 String 2 Object 3 ...
- 跟我学SharePoint 2013视频培训课程——排序、过滤在列表、库中的使用(10)
课程简介 第10天,SharePoint 2013排序.过滤在列表.库中的使用. 视频 SharePoint 2013 交流群 41032413
- SQL 正则表达式 `(user_log_acct)?+.+`
SELECT 语句可以使用正则表达式做列选择,下面的语句查询除了 ds 和 hr 之外的所有列: SELECT `(ds|hr)?+.+` FROM test