cocos2d-x  2.1.1

CCTouchDispatcher. More...

#include <CCTouchDispatcher.h>

Inheritance diagram for CCTouchDispatcher:
CCObject EGLTouchDelegate CCCopying

Public Member Functions

 ~CCTouchDispatcher ()
 
bool init (void)
 
 CCTouchDispatcher ()
 
bool isDispatchEvents (void)
 Whether or not the events are going to be dispatched.
 
void setDispatchEvents (bool bDispatchEvents)
 
void addStandardDelegate (CCTouchDelegate *pDelegate, int nPriority)
 Adds a standard touch delegate to the dispatcher's list.
 
void addTargetedDelegate (CCTouchDelegate *pDelegate, int nPriority, bool bSwallowsTouches)
 Adds a targeted touch delegate to the dispatcher's list.
 
void removeDelegate (CCTouchDelegate *pDelegate)
 Removes a touch delegate.
 
void removeAllDelegates (void)
 Removes all touch delegates, releasing all the delegates.
 
void setPriority (int nPriority, CCTouchDelegate *pDelegate)
 Changes the priority of a previously added delegate.
 
void touches (CCSet *pTouches, CCEvent *pEvent, unsigned int 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)
 
CCTouchHandlerfindHandler (CCTouchDelegate *pDelegate)
 
- Public Member Functions inherited from CCObject
 CCObject (void)
 
virtual ~CCObject (void)
 
void release (void)
 
void retain (void)
 
CCObjectautorelease (void)
 
CCObjectcopy (void)
 
bool isSingleReference (void)
 
unsigned int retainCount (void)
 
virtual bool isEqual (const CCObject *pObject)
 
virtual void update (float dt)
 
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)
 
- Public Member Functions inherited from EGLTouchDelegate
virtual ~EGLTouchDelegate ()
 

Protected Member Functions

void forceRemoveDelegate (CCTouchDelegate *pDelegate)
 
void forceAddHandler (CCTouchHandler *pHandler, CCArray *pArray)
 
void forceRemoveAllDelegates (void)
 
void rearrangeHandlers (CCArray *pArray)
 
CCTouchHandlerfindHandler (CCArray *pArray, CCTouchDelegate *pDelegate)
 

Protected Attributes

CCArraym_pTargetedHandlers
 
CCArraym_pStandardHandlers
 
bool m_bLocked
 
bool m_bToAdd
 
bool m_bToRemove
 
CCArraym_pHandlersToAdd
 
struct _ccCArray * m_pHandlersToRemove
 
bool m_bToQuit
 
bool m_bDispatchEvents
 
struct ccTouchHandlerHelperData m_sHandlerHelperData [ccTouchMax]
 
- Protected Attributes inherited from CCObject
unsigned int m_uReference
 
unsigned int m_uAutoReleaseCount
 

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
 
int m_nLuaID
 

Detailed Description

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

Constructor & Destructor Documentation

CCTouchDispatcher ( )
inline

Member Function Documentation

void addStandardDelegate ( CCTouchDelegate pDelegate,
int  nPriority 
)

Adds a standard touch delegate to the dispatcher's list.

See StandardTouchDelegate description. IMPORTANT: The delegate will be retained.

void addTargetedDelegate ( CCTouchDelegate pDelegate,
int  nPriority,
bool  bSwallowsTouches 
)

Adds a targeted touch delegate to the dispatcher's list.

See TargetedTouchDelegate description. IMPORTANT: The delegate will be retained.

CCTouchHandler* findHandler ( CCTouchDelegate pDelegate)
CCTouchHandler* findHandler ( CCArray pArray,
CCTouchDelegate pDelegate 
)
protected
void forceAddHandler ( CCTouchHandler pHandler,
CCArray pArray 
)
protected
void forceRemoveAllDelegates ( void  )
protected
void forceRemoveDelegate ( CCTouchDelegate pDelegate)
protected
bool init ( void  )
bool isDispatchEvents ( void  )

Whether or not the events are going to be dispatched.

Default: true

void rearrangeHandlers ( CCArray pArray)
protected
void removeAllDelegates ( void  )

Removes all touch delegates, releasing all the delegates.

void removeDelegate ( CCTouchDelegate pDelegate)

Removes a touch delegate.

The delegate will be released

void setDispatchEvents ( bool  bDispatchEvents)
void setPriority ( int  nPriority,
CCTouchDelegate pDelegate 
)

Changes the priority of a previously added delegate.

The lower the number, the higher the priority

void touches ( CCSet pTouches,
CCEvent pEvent,
unsigned int  uIndex 
)
virtual void touchesBegan ( CCSet touches,
CCEvent pEvent 
)
virtual

Implements EGLTouchDelegate.

virtual void touchesCancelled ( CCSet touches,
CCEvent pEvent 
)
virtual

Implements EGLTouchDelegate.

virtual void touchesEnded ( CCSet touches,
CCEvent pEvent 
)
virtual

Implements EGLTouchDelegate.

virtual void touchesMoved ( CCSet touches,
CCEvent pEvent 
)
virtual

Implements EGLTouchDelegate.

Member Data Documentation

bool m_bDispatchEvents
protected
bool m_bLocked
protected
bool m_bToAdd
protected
bool m_bToQuit
protected
bool m_bToRemove
protected
CCArray* m_pHandlersToAdd
protected
struct _ccCArray* m_pHandlersToRemove
protected
CCArray* m_pStandardHandlers
protected
CCArray* m_pTargetedHandlers
protected
struct ccTouchHandlerHelperData m_sHandlerHelperData[ccTouchMax]
protected

The documentation for this class was generated from the following file: