CCTouchDispatcher
来源:互联网 发布:销售提成算法 编辑:程序博客网 时间:2024/06/05 14:41
#ifndef __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
#define __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
#include "CCTouchDelegateProtocol.h"
#include "cocoa/CCObject.h"
#include "cocoa/CCArray.h"
NS_CC_BEGIN
/**
* @addtogroup input
* @{
*/
typedef enum
{
ccTouchSelectorBeganBit = 1 << 0,
ccTouchSelectorMovedBit = 1 << 1,
ccTouchSelectorEndedBit = 1 << 2,
ccTouchSelectorCancelledBit = 1 << 3,
ccTouchSelectorAllBits = ( ccTouchSelectorBeganBit |ccTouchSelectorMovedBit |ccTouchSelectorEndedBit |ccTouchSelectorCancelledBit),
} ccTouchSelectorFlag;
enum {
CCTOUCHBEGAN,
CCTOUCHMOVED,
CCTOUCHENDED,
CCTOUCHCANCELLED,
ccTouchMax,
};
class CCSet;
class CCEvent;
struct ccTouchHandlerHelperData {
// we only use the type
// void (StandardTouchDelegate::*touchesSel)(CCSet*, CCEvent*);
// void (TargetedTouchDelegate::*touchSel)(NSTouch*, CCEvent*);
int m_type;
};
class CC_DLL EGLTouchDelegate
{
public:
virtual void touchesBegan(CCSet* touches,CCEvent* pEvent) =0;
virtual void touchesMoved(CCSet* touches,CCEvent* pEvent) =0;
virtual void touchesEnded(CCSet* touches,CCEvent* pEvent) =0;
virtual void touchesCancelled(CCSet* touches,CCEvent* pEvent) =0;
virtual ~EGLTouchDelegate() {}
};
class CCTouchHandler;
struct _ccCArray;
/** @brief CCTouchDispatcher.
Singleton that handles all the touch events.
The dispatcher dispatches events to the registered TouchHandlers.
There are 2 different type of touch handlers:
- Standard Touch Handlers
- Targeted Touch Handlers
The Standard Touch Handlers work like the CocoaTouch touch handler: a set of touches is passed to the delegate.
On the other hand, the Targeted Touch Handlers only receive 1 touch at the time, and they can "swallow" touches (avoid the propagation of the event).
Firstly, the dispatcher sends the received touches to the targeted touches.
These touches can be swallowed by the Targeted Touch Handlers. If there are still remaining touches, then the remaining touches will be sent
to the Standard Touch Handlers.
@since v0.8.0
*/
class CC_DLL CCTouchDispatcher :publicCCObject,publicEGLTouchDelegate
{
public:
~CCTouchDispatcher();
bool init(void);
CCTouchDispatcher()
: m_pTargetedHandlers(NULL)
, m_pStandardHandlers(NULL)
, m_pHandlersToAdd(NULL)
, m_pHandlersToRemove(NULL)
{}
public:
/** Whether or not the events are going to be dispatched. Default: true */
bool isDispatchEvents(void);
void setDispatchEvents(bool bDispatchEvents);
/** Adds a standard touch delegate to the dispatcher's list.
See StandardTouchDelegate description.
IMPORTANT: The delegate will be retained.
*/
void addStandardDelegate(CCTouchDelegate *pDelegate,int nPriority);
/** Adds a targeted touch delegate to the dispatcher's list.
See TargetedTouchDelegate description.
IMPORTANT: The delegate will be retained.
*/
void addTargetedDelegate(CCTouchDelegate *pDelegate,int nPriority,bool bSwallowsTouches);
/** Removes a touch delegate.
The delegate will be released
*/
void removeDelegate(CCTouchDelegate *pDelegate);
/** Removes all touch delegates, releasing all the delegates */
void removeAllDelegates(void);
/** Changes the priority of a previously added delegate. The lower the number,
the higher the priority */
void setPriority(int nPriority,CCTouchDelegate *pDelegate);
void touches(CCSet *pTouches,CCEvent *pEvent,unsignedint uIndex);
virtual void touchesBegan(CCSet* touches,CCEvent* pEvent);
virtual void touchesMoved(CCSet* touches,CCEvent* pEvent);
virtual void touchesEnded(CCSet* touches,CCEvent* pEvent);
virtual void touchesCancelled(CCSet* touches,CCEvent* pEvent);
public:
CCTouchHandler* findHandler(CCTouchDelegate *pDelegate);
protected:
void forceRemoveDelegate(CCTouchDelegate *pDelegate);
void forceAddHandler(CCTouchHandler *pHandler,CCArray* pArray);
void forceRemoveAllDelegates(void);
void rearrangeHandlers(CCArray* pArray);
CCTouchHandler* findHandler(CCArray* pArray,CCTouchDelegate *pDelegate);
protected:
CCArray* m_pTargetedHandlers;
CCArray* m_pStandardHandlers;
bool m_bLocked;
bool m_bToAdd;
bool m_bToRemove;
CCArray* m_pHandlersToAdd;
struct _ccCArray *m_pHandlersToRemove;
bool m_bToQuit;
bool m_bDispatchEvents;
// 4, 1 for each type of event
structccTouchHandlerHelperData m_sHandlerHelperData[ccTouchMax];
};
// end of input group
/// @}
NS_CC_END
#endif // __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__
- CCTouchDispatcher
- cocos2d CCTouchDispatcher 触摸分发
- CCTouchDispatcher的问题
- CCTouchDispatcher测试总结
- CCLayer中使用registerWithTouchDispatcher注册CCTouchDispatcher
- Cocos2d-x之CCTouchDispatcher事件分发
- assert error : cctouchdispatcher forceaddhandler line 121 || android
- CCLayer中使用registerWithTouchDispatcher注册CCTouchDispatcher
- Cocos2d-x之CCTouchDispatcher事件分发
- hadoop学习-Netflix电影推荐系统
- Linux启动报错UNEXPECTED INCONSISTENCY解决方法
- python外部传参
- SpringMVC3的ResponseBody返回字符串乱码问题解决
- 使用 JFreeChart 来创建基于 web 的图表
- CCTouchDispatcher
- 用java调用oracle存储过程总结
- Tomcat服务器集群与负载均衡实现
- File "scripts/rule_bison.py", line 75, in <module>
- 20140522
- [1337] Dumb Typo
- 一 oracle 数据库 分类
- void及void指针含义的深刻解析
- nyoj-3-多边形重心问题