您的位置:首页 > 移动开发 > Cocos引擎

cocos2d-x节点(CCEventTouch.h)API

2013-12-04 09:03 387 查看
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!


cocos2d-x节点(CCEventTouch.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

触摸事件
///cocos2d/cocos2d-x-3.0alpha0/cocos2dx/event_dispatcher
//触摸事件

#ifndef __cocos2d_libs__TouchEvent__
#define __cocos2d_libs__TouchEvent__

#include "CCEvent.h"
#include "event_dispatcher/CCTouch.h"
#include <vector>

NS_CC_BEGIN

#define TOUCH_PERF_DEBUG 1

class EventTouch : public Event
{
public:
static const char* EVENT_TYPE;
static const int MAX_TOUCHES = 5;

enum class EventCode
{
BEGAN,
MOVED,
ENDED,
CANCELLED
};

EventTouch()
: Event(EVENT_TYPE)
{
_touches.reserve(MAX_TOUCHES);
}

EventCode getEventCode() { return _eventCode; };
std::vector<Touch*> getTouches() { return _touches; };

#if TOUCH_PERF_DEBUG
void setEventCode(EventCode eventCode) { _eventCode = eventCode; };
void setTouches(const std::vector<Touch*>& touches) { _touches = touches; };
#endif

private:
EventCode _eventCode;
std::vector<Touch*> _touches;

friend class EGLViewProtocol;
};

NS_CC_END

#endif /* defined(__cocos2d_libs__TouchEvent__) */
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: