Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUAccelerationPoller.h>
Public Member Functions | |
bool | isActive () const |
const Acceleration & | getAcceleration () const |
void | accleromCB (Acceleration *acc, Event *event) |
~AccelerationPoller () | |
void | init (int priority) |
void | init (Node *node) |
void | dispose () |
Static Public Member Functions | |
static void | start (int priority) |
static void | start (Node *node) |
static void | stop () |
static AccelerationPoller * | getInstance () |
Public Attributes | |
CC_CONSTRUCTOR_ACCESS | __pad0__: AccelerationPoller() |
Protected Attributes | |
EventListenerAcceleration * | _accelListener |
Acceleration | _acceleration |
bool | _active |
Static Protected Attributes | |
static AccelerationPoller * | _gAcceleration = nullptr |
Class to providing a polling interface for the Accelerometer.
Cocos2d decided to make all of its input event-driven. This is a major problem, because it is hard to associate the events with the current animation frame, potentially causing lag. A poller is an alternative input interface that allows us to query the current state of the keyboard when we need it.
Because there is (theoretically) only one accelerometer, this class provides a singleton interface. You can start and stop the interface with static methods.
AccelerationPoller::~AccelerationPoller | ( | ) |
Disposes of this input controller, releasing all listeners.
void AccelerationPoller::accleromCB | ( | Acceleration * | acc, |
Event * | event | ||
) |
Callback for a change in accelerometer state
acc | The accelerometer information |
event | The associated event |
void AccelerationPoller::dispose | ( | ) |
Stops this listener, so that it no longer receives events
|
inline |
Returns the most recent acceleration value.
|
static |
Returns the singleton interface for the acceleration poller.
It is unsafe to make your own acceleration poller. Just use this static method to access the singleton object.
This method will return nullptr if the poller is not yet started.
Returns the singleton interface for the keyboard poller.
It is unsafe to make your own keyboard poller. Just use this static method to access the singleton object.
This method will return nullptr if the poller is not yet started.
void AccelerationPoller::init | ( | int | priority | ) |
Initializes this listener, registering it to receive events.
The listener has fixed priority.
priority | The input priority for the listener. |
void AccelerationPoller::init | ( | Node * | node | ) |
Initializes this listener, registering it to receive events.
The listener has scene priority.
node | The node for scene priority. |
|
inline |
Returns whether this listener is active and receiving events
Returns whether this listener is active and receiving events
|
static |
Starts the input processing for this poller.
This method will activate the singleton and assign it a priority. The listener has fixed priority.
priority | The input priority for the keyboard. |
|
static |
Starts the input processing for this poller.
This method will activate the singleton and assign it a priority. The listener has scene priority.
node | The node for scene priority. |
|
static |
Stop the input processing for this input controller.
This will deallocate the singleton, freeing memory.
|
protected |
The most recent acceleration value
|
protected |
Listener to process keyboard events
|
protected |
Whether this listener is active and receiving events
|
staticprotected |
Singleton accleraton controller
Initialization of static reference