1.处理屏幕触摸(单点触摸)
2016-05-24 16:41
351 查看
单点触摸
步骤:1.需要设置一个tag值监听才能找到
2.监听事件//1.创建监听对象
auto listener = EventListenerTouchOneByOne::create();
//2.定义监听对象的回调方法
listener->onTouchBegin = CC_CALLBACK_2(HelloWorld::onTouchBegin,this);
listener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved,this);
listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded,this);
//3.事件分发器中注册
_eventDispatcher->addEventLsitenerWithSceneGraphPriority(listener,this);
3.监听事件的实现
bool HelloWorld::onTouchBegin(Touch* touch,Event *event){ auto lis = this->getChildByTag(111); lis->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2)); return true; } void HelloWorld::onTouchMoved(Touch* touch,Event* event){ auto moveLis = this->getChildByTag(111); moveLis->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2)); }
相关文章推荐
- 视图添加移动手势
- jQuery前端开发35个小技巧
- ZOJ-1610 Count the Colors
- centos7安装docker
- POJ 1251
- [文摘20160524]为什么你的孩子不像德国孩子那样自律?看过这个就知道怎么做了!
- iOS常识名词解释 2016/04/05
- tabBar的图标不被系统渲染
- Clang Format
- C++ 值传递、指针传递、引用传递
- mysql 修改data目录后 无法使用脚本启动 推荐
- 第13周-交通类(3)
- 模拟实现部分库函数(strcpy,strcmp,strcat,strstr,memcpy,memmove,memset)
- Picasso 图片请求库(工具类)
- Open Baidu webpage and type in Chinese characters to start searching, press “Back” button to go to B
- 3、Git基本的工作流程
- HDU 1669 Monkey and Banana
- JavaScript学习
- RRC连接重配置
- java中GC回收和内存分配