Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUMultiTouchListener.h>
Public Member Functions | |
void | start (int priority) |
void | start (Node *node) |
void | stop () |
bool | isActive () const |
bool | init () |
bool | init (EventDispatcher *dispatcher) |
Static Public Member Functions | |
static MultiTouchListener * | create () |
static MultiTouchListener * | create (EventDispatcher *dispatcher) |
Public Attributes | |
std::function< void(const std::vector< Touch * > &touches, timestamp_t time)> | onTouchesBegan |
std::function< void(const std::vector< Touch * > &touches, timestamp_t time)> | onTouchesMoved |
std::function< void(const std::vector< Touch * > &touches, timestamp_t time)> | onTouchesEnded |
std::function< void(const std::vector< Touch * > &touches, timestamp_t time)> | onTouchesCancelled |
CC_CONSTRUCTOR_ACCESS | __pad0__: MultiTouchListener() : _active(false) {} virtual ~MultiTouchListener() |
Protected Attributes | |
EventDispatcher * | _dispatcher |
EventListenerTouchAllAtOnce * | _touchListener |
bool | _active |
Class provides a time senstive touch listener.
When created, this class initializes but does not activate a touch listener. You must use the start and stop methods to activate/deactivate the listener. Furthermore, all of the callback functions are originally undefined. They must be defined before this listener performs any useful functionality.
This class simplifies a lot of the overhead for EventListenerTouchAllAtOnce. More importantly,it adds a timestamp to all of the callback functions so that the user can precisely time the callbacks.
While TouchListener can handle multitouch events, this listener is preferred if you are trying to coordinate the touches, such as in gesture recognition.
|
static |
Creates a new input controller for the default dispatcher.
a reference to the default event dispatcher
|
static |
Creates a new input controller for the given dispatcher.
dispatcher | Event handler for callbacks. |
a reference to the event dispatcher
|
inline |
Initializes a new input controller for the default dispatcher.
bool MultiTouchListener::init | ( | EventDispatcher * | dispatcher | ) |
Creates a new input controller for the given dispatcher.
dispatcher | Event handler for callbacks. |
a reference to the event dispatcher
|
inline |
Returns whether this listener is active and receiving events
Returns whether this listener is active and receiving events
void MultiTouchListener::start | ( | int | priority | ) |
Starts this listener, registering it to receive events.
The listener has fixed priority.
priority | The input priority for the listener. |
void MultiTouchListener::start | ( | Node * | node | ) |
Starts this listener, registering it to receive events.
The listener has scene priority.
node | The node for scene priority. |
void MultiTouchListener::stop | ( | ) |
Stops this listener, so that it no longer receives events
|
protected |
Whether this listener is active and receiving events
|
protected |
The event dispatching handling input for this controller
|
protected |
Listener to process touch events
std::function<void(const std::vector<Touch*>& touches, timestamp_t time)> MultiTouchListener::onTouchesBegan |
Called when a multitouch event first starts
touches | the collective touch state |
time | the time of the event |
std::function<void(const std::vector<Touch*>& touches, timestamp_t time)> MultiTouchListener::onTouchesCancelled |
Called when a multitouch event is aborted
Cancellation occurs when an external event—for example, an incoming phone call—disrupts the current app’s event processing.
touches | the collective touch state |
time | the time of the event |
std::function<void(const std::vector<Touch*>& touches, timestamp_t time)> MultiTouchListener::onTouchesEnded |
Called when a multitouch event completes
touches | the collective touch state |
time | the time of the event |
std::function<void(const std::vector<Touch*>& touches, timestamp_t time)> MultiTouchListener::onTouchesMoved |
Called when a multitouch event moves.
If this event handler runs on a desktop with a mouse, this event will only register if the mouse is moved while a button is held down.
touches | the collective touch state |
time | the time of the event |