博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocos2dx 点击事件分析(1)
阅读量:4216 次
发布时间:2019-05-26

本文共 1479 字,大约阅读时间需要 4 分钟。

CCTouch类是每个点击事件处理过程中,都需要使用的类,因为android的屏幕坐标和OpenGL的坐标的不同,而且在屏幕适配时,有缩放,所以需要把屏幕坐标转化为OpenGL的坐标坐标。class CC_DLL CCTouch : public CCObject{public:    /**     * @js ctor     */    CCTouch()        : m_nId(0),        m_startPointCaptured(false)    {}    /** returns the current touch location in OpenGL coordinates */    CCPoint getLocation() const;    /** returns the previous touch location in OpenGL coordinates */    CCPoint getPreviousLocation() const;    /** returns the start touch location in OpenGL coordinates */    CCPoint getStartLocation() const;    /** returns the delta of 2 current touches locations in screen coordinates */    CCPoint getDelta() const;    /** returns the current touch location in screen coordinates */    CCPoint getLocationInView() const;    /** returns the previous touch location in screen coordinates */    CCPoint getPreviousLocationInView() const;    /** returns the start touch location in screen coordinates */    CCPoint getStartLocationInView() const;        void setTouchInfo(int id, float x, float y)    {        m_nId = id;        m_prevPoint = m_point;        m_point.x   = x;        m_point.y   = y;        if (!m_startPointCaptured)        {            m_startPoint = m_point;            m_startPointCaptured = true;        }    }    /**     *  @js getId     */    int getID() const    {        return m_nId;    }private:    int m_nId;    bool m_startPointCaptured;    CCPoint m_startPoint;    CCPoint m_point;    CCPoint m_prevPoint;};

转载地址:http://ltsmi.baihongyu.com/

你可能感兴趣的文章
cocos2dx使用第三方字库.ttf,需要注意的事项
查看>>
cocos2dx 音频模块分析(4): 音效部分
查看>>
cocos2dx 音频模块分析(5): 音效部分
查看>>
19、Cocos2dx 3.0游戏开发找小三之Action:流动的水没有形状,漂流的风找不到踪迹、、、
查看>>
cocos2.X版本lua端使用定时器的方法
查看>>
lua math.fmod使用注意小数问题
查看>>
lua 时间转化
查看>>
lua学习笔记之五(Lua中的数学库)
查看>>
dos: tree命令生成目录结构
查看>>
Managing Projects from the Command Line(android官网文档)
查看>>
Android项目自动生成build.xml,用Ant打包
查看>>
CCLayer注册lua回调函数setTouchPriority失效
查看>>
cocos2dx左下角三行数值意义
查看>>
LUA modue require package 区别
查看>>
package.loaded
查看>>
cocoStudio: Button设置锚点问题
查看>>
vld 使用
查看>>
MAC下安装多版本JDK和切换几种方式
查看>>
java.util.concurrent详解
查看>>
java事务大总结(一) 先理解数据库的事务以mysql为例
查看>>