本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(CCEventListenerTouch.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
触摸事件监听
///cocos2d/cocos2d-x-3.0alpha0/cocos2dx/event_dispatcher
//触摸事件监听
#ifndef __cocos2d_libs__CCTouchEventListener__
#define __cocos2d_libs__CCTouchEventListener__
#include "CCEventListener.h"
#include "event_dispatcher/CCTouch.h"
#include <vector>
NS_CC_BEGIN
class EventListenerTouch : public EventListener
{
public:
static EventListenerTouch* create(Touch::DispatchMode mode);
/// Overrides
virtual EventListenerTouch* clone() override;
virtual bool checkAvaiable() override;
virtual ~EventListenerTouch();
private:
EventListenerTouch();
bool init(Touch::DispatchMode mode);
public:
std::function<bool(Touch*, Event*)> onTouchBegan;
std::function<void(Touch*, Event*)> onTouchMoved;
std::function<void(Touch*, Event*)> onTouchEnded;
std::function<void(Touch*, Event*)> onTouchCancelled;
std::function<void(const std::vector<Touch*>&, Event*)> onTouchesBegan;
std::function<void(const std::vector<Touch*>&, Event*)> onTouchesMoved;
std::function<void(const std::vector<Touch*>&, Event*)> onTouchesEnded;
std::function<void(const std::vector<Touch*>&, Event*)> onTouchesCancelled;
void setSwallowTouches(bool needSwallow);
private:
std::vector<Touch*> _claimedTouches;
bool _needSwallow;
Touch::DispatchMode _dispatchMode;
friend class EventDispatcher;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCTouchEventListener__) */