cocos2dx 点击事件分析(1)
发布时间:2020-12-14 20:43:44 所属栏目:百科 来源:网络整理
导读:CCTouch类是每个点击事件处理过程中,都需要使用的类,因为android的屏幕坐标和OpenGL的坐标的不同,而且在屏幕适配时,有缩放,所以需要把屏幕坐标转化为OpenGL的坐标坐标。class CC_DLL CCTouch : public CCObject{public: /** * @js ctor */ CCTouch() :
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; }; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |