cocos2d 单点触控
//
// Single.hpp
// dev
//
// Created by sun on 15/12/20.
//
//
#ifndef Single_hpp
#define Single_hpp
#include <stdio.h>
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
class Single : public CCLayer
{
public:
virtual bool init();
static CCScene* scene();
CREATE_FUNC(Single);
//touch
private:
void registerWithTouchDispatcher(void);
bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
};
#endif /* Single_hpp */
//
// Single.cpp
// dev
//
// Created by sun on 15/12/20.
//
//
#include "Single.hpp"
CCScene* Single::scene()
{
CCScene *scene = CCScene::create();
Single *layer = Single::create();
scene->addChild(layer);
return scene;
}
bool Single::init()
{
if ( !CCLayer::init() )
{
return false;
}
this->setTouchEnabled(true);
return true;
}
void Single::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
}
bool Single::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
CCPoint touchpoint = pTouch->getLocation(); //获取触摸坐标
CCLOG("touch began, touchpoint is %f %f", touchpoint.x,touchpoint.y);
CCScene* helloscene=HelloWorld::scene();
CCDirector::sharedDirector()->replaceScene(helloscene);
return true; //true表示继续响应CCTouchMove,CCTouchEnd,CCTouchCancalled,false表示不响应。
}
void Single::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
CCPoint touchpoint = pTouch->getLocation(); //获取触摸坐标
CCLOG("touch moved, touchpoint is %f %f", touchpoint.x,touchpoint.y);
}
void Single::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
CCPoint touchpoint = pTouch->getLocation(); //获取触摸坐标
CCLOG("touch ended, touchpoint is %f %f", touchpoint.x,touchpoint.y);
}
void Single::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
{
CCPoint touchpoint = pTouch->getLocation(); //获取触摸坐标
CCLOG("touch cancelled, touchpoint is %f %f", touchpoint.x,touchpoint.y);
}
cocos2d 单点触控的更多相关文章
- COCOS学习笔记--单点触控
这篇博客来总结下cocos单点触控的相关内容: 我们在Layer类的源代码中能够看到.Layer类提供了一下4个与屏幕单点触控相关的回调方法: onTouchBegan().onTouchMoved( ...
- 新鲜出炉:appium2.0+ 单点触控和多点触控新的解决方案
在 appium2.0 之前,在移动端设备上的触屏操作,单手指触屏和多手指触屏分别是由 TouchAction 类,Multiaction 类实现的. 在 appium2.0 之后,这 2 个方法将会 ...
- cocos2d 多点触控
#ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" USING_N ...
- 安卓贴图源码--->单点触控.多点触控.类似in/百度魔图
效果如图: 类似in,百度魔图,的贴图功能 核心的地方:单/多点 旋转缩放后记录各个顶点小图标位置 引用这里 http://blog.csdn.net/xiaanming/article/detai ...
- ccc 单点触控
cc.Class({ extends: cc.Component, properties: { }, // use this for initialization onLoad: function ( ...
- android——单点触控移动,多点触控放大缩小
xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...
- cocos2d-x 多点触控实现缩放及相关问题的解决方法
首先,来看下代码: 声明文件: #ifndef __loading__MoreTouches__ #define __loading__MoreTouches__ #include <iostr ...
- cocos2d3.x在android下屏蔽多点触控
ios上很简单的在AppController.mm里 [eaglView setMultipleTouchEnabled:YES] 设置为NO,就是单点触控了,无需更改cocos底层代码; andro ...
- ccc 多点触控2
经过不断的思考发现,如果是两个sprite都添加触控的时候,往往直接成单点触控, 但是如果是两个node的时候在node上面点击就会变成多点触控的形式 cc.Class({ extends: cc.C ...
随机推荐
- 【NGUI】grid下面的item的重复利用
http://blog.csdn.net/u012091672/article/details/21159075解决的问题 使用grid放置item的时候,每次数据可能都不一样,但是每次都删除grid ...
- Stanford机器学习---第五讲. 神经网络的学习 Neural Networks learning
原文 http://blog.csdn.net/abcjennifer/article/details/7758797 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...
- 配置oss bucket cors
到bucket中属性中选择跨越设置,点击添加规则会看到以下界面: 对应的输入如上即可.
- [ruby on rails] 跟我学之(5)显示所有数据
之前的index页,显示的是hello world,现在将其修改为显示我们在rails console里面录入的数据. 1. 修改action 如之前的章节<[ruby on rails] 跟我 ...
- luarocks install with lua5.1 and luajit to install lapis
# in luarocks source directory...git clone https://github.com/archoncap/luarockscd luarocks ./config ...
- 【SpringMVC】SpringMVC系列2之@RequestMapping 映射约束请求
@RequestMapping 映射约束请求 2.1.映射请求URL Spring MVC 使用 @RequestMapping 注解为控制器指定可以处理哪些 URL 请求,在控制器的类定义及方法定义 ...
- Subarray Sum & Maximum Size Subarray Sum Equals K
Subarray Sum Given an integer array, find a subarray where the sum of numbers is zero. Your code sho ...
- iOS 中的字体预览
要预览iOS的各种字体的效果,可以访问http://iosfonts.com
- 【JAVA、C++】LeetCode 004 Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...
- 项目总结(五)--- 界面调试工具Reveal
在开发中,我们也许会碰到以下需求:对于一些动态复杂的交互界面,手码去制定界面是常有的事情,然而我们在开发中想修改过一些参数后想看下实时效果,只能重新运行项目,进入到对应的页面来进行修改,是不是有点麻烦 ...