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 ...
随机推荐
- [Effective JavaScript 笔记]第56条:避免不必要的状态
API有时被归为两类:有状态的和无状态的.无状态的API提供的函数或方法的行为只取决于输入,而与程序的状态改变无关.字符串的方法是无状态的.字符串的内容不能被修改,方法只取决于字符串的内容及传递给方法 ...
- ios数据库
1. ios数据库管理软件 ios使用的数据库是sqlite 管理软件有2种, 我只记得一种, 名字叫做 MesaSQLite 2. sqlite数据库 2.1.修改表结构 ①:更改字段类型长度 AL ...
- 使用 nginx + thin 的配置启动 rails server
http://www.iwangzheng.com 在大师的指导下配置了新的服务器的nginx,通过top命令查看了服务器是8个cpu的,所以起了8个端口,把它们都映射到一个总的端口3600上,需要在 ...
- MySQL sql语句总结
1.说明:创建数据库CREATE DATABASE database-name2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备份数据的 d ...
- Delphi开发Windows服务程序
开发步骤: 1.New->Other->Service Application 2.现在一个服务程序的框架已经搭起来了 打开Service1窗口,有几个属性说明一下: AllowPause ...
- Java--时间处理
package javatest; import java.text.SimpleDateFormat; import java.util.Date; class timeTest{ public s ...
- Java中成员变量和局部变量的区别
java面向对象过程中,最基本的两类变量就是成员变量和局部变量 成员变量是写在类中并且写在方法外部,一般写在每个类的头部,用于初始化或者方法操作,作用域是整个类被实例化到被销毁,中间变量都可以被外部方 ...
- ts tp 高清播放软件 Elecard MPEG Player 6.0.130827
Elecard MPEG Player 6.0.130827 计算机配置不高的情况下,流畅播放高清视频. 缺点是搜索时停顿严重. 包里有注册机. 下载地址 http://pan.baidu.com/s ...
- Java for LeetCode 189 Rotate Array
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array ...
- hdu 1232 畅通工程 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1232 并查集入门题.最近在学并查集,它无非包括三个操作:make_set(x).union_set(x ...