axmol/tools/tolua++/CCTouchDispatcher.pkg

112 lines
3.4 KiB
Plaintext

namespace cocos2d {
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 EGLTouchDelegate
{
public:
void touchesBegan(CCSet* touches, CCEvent* pEvent);
void touchesMoved(CCSet* touches, CCEvent* pEvent) ;
void touchesEnded(CCSet* touches, CCEvent* pEvent) ;
void touchesCancelled(CCSet* touches, CCEvent* pEvent) ;
~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 CCTouchDispatcher : public CCObject, public EGLTouchDelegate
{
~CCTouchDispatcher();
bool init(void);
CCTouchDispatcher();
/** 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, unsigned int uIndex);
void touchesBegan(CCSet* touches, CCEvent* pEvent);
void touchesMoved(CCSet* touches, CCEvent* pEvent);
void touchesEnded(CCSet* touches, CCEvent* pEvent);
void touchesCancelled(CCSet* touches, CCEvent* pEvent);
/** singleton of the CCTouchDispatcher */
static CCTouchDispatcher* sharedDispatcher();
};
}//namespace cocos2d