//
// 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 单点触控的更多相关文章

  1. COCOS学习笔记--单点触控

    这篇博客来总结下cocos单点触控的相关内容: 我们在Layer类的源代码中能够看到.Layer类提供了一下4个与屏幕单点触控相关的回调方法: onTouchBegan().onTouchMoved( ...

  2. 新鲜出炉:appium2.0+ 单点触控和多点触控新的解决方案

    在 appium2.0 之前,在移动端设备上的触屏操作,单手指触屏和多手指触屏分别是由 TouchAction 类,Multiaction 类实现的. 在 appium2.0 之后,这 2 个方法将会 ...

  3. cocos2d 多点触控

    #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" USING_N ...

  4. 安卓贴图源码--->单点触控.多点触控.类似in/百度魔图

    效果如图: 类似in,百度魔图,的贴图功能  核心的地方:单/多点 旋转缩放后记录各个顶点小图标位置 引用这里 http://blog.csdn.net/xiaanming/article/detai ...

  5. ccc 单点触控

    cc.Class({ extends: cc.Component, properties: { }, // use this for initialization onLoad: function ( ...

  6. android——单点触控移动,多点触控放大缩小

    xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...

  7. cocos2d-x 多点触控实现缩放及相关问题的解决方法

    首先,来看下代码: 声明文件: #ifndef __loading__MoreTouches__ #define __loading__MoreTouches__ #include <iostr ...

  8. cocos2d3.x在android下屏蔽多点触控

    ios上很简单的在AppController.mm里 [eaglView setMultipleTouchEnabled:YES] 设置为NO,就是单点触控了,无需更改cocos底层代码; andro ...

  9. ccc 多点触控2

    经过不断的思考发现,如果是两个sprite都添加触控的时候,往往直接成单点触控, 但是如果是两个node的时候在node上面点击就会变成多点触控的形式 cc.Class({ extends: cc.C ...

随机推荐

  1. Inheritance

    Often, classes will have shared characteristics with other classes. Rewriting the same methods for e ...

  2. poj2485 Highways

    Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public h ...

  3. Android创建桌面快捷图标

    <!-- 添加快捷方式 --> <uses-permission android:name="com.android.launcher.permission.INSTALL ...

  4. Bellman-Ford算法

    #include<stdio.h> #define max 0xffffff ][]; //图的邻接矩阵 ]; int n;//顶点个数 int m;//边个数 struct Edge { ...

  5. c# 继承,多态,new /overrid 区别, 引用父类的方法

    好久没碰c#了,偶尔需要制作点小工具.为了一个灵活的架构设计,需要对继承/多态有比较深刻的理解. 不料忘得差不多了,好吧,再来回忆下.直接上代码了,如下: using System; using Sy ...

  6. BZOJ 1600

    开始刷一些USACO月赛题了.. 这题简单递推就不说了. 然后我们发现暴力递推是$O(n^2)$的.看起来非常慢. 这道题拥有浓厚的数学色彩,因此我们可以从数学它的规律上找突破口. (于是暴力大法好, ...

  7. Unable to mount the CD/DVD image virtualbox解决方法

    转自: http://askubuntu.com/questions/321589/unable-to-mount-the-cd-dvd-image-on-the-machine-sandbox

  8. 【原创】Mapped Statements collection does not contain value for DaoImpl.method

    问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Pers ...

  9. Java入门学习知识点汇总

    Java入门重要知识点在这里总结一下,以方便日后复习,这部分内容主要有:变量和常量,常用的运算符,流程控制语句,数组,方法这些内容 一.变量和常量 1.Java关键字 先贴张图: 所有关键字区分大小写 ...

  10. HDU1695 GCD (欧拉函数+容斥原理)

    F - GCD Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...