The base class of event listener.
More...
#include <CCEventListener.h>
The base class of event listener.
If you need custom listener which with different callback, you need to inherit this class. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, EventListenerTouchOneByOne, EventListenerCustom.
virtual bool checkAvailable |
( |
| ) |
|
|
pure virtual |
Clones the listener, its subclasses have to override this method.
Implemented in EventListenerPhysicsContactWithGroup, EventListenerPhysicsContactWithShapes, EventListenerPhysicsContactWithBodies, EventListenerPhysicsContact, EventListenerTouchAllAtOnce, EventListenerCustom, EventListenerTouchOneByOne, EventListenerAssetsManagerEx, EventListenerFocus, EventListenerAcceleration, EventListenerController, EventListenerKeyboard, and EventListenerMouse.
Clones the listener, its subclasses have to override this method.
Implemented in EventListenerPhysicsContactWithGroup, EventListenerPhysicsContactWithShapes, EventListenerPhysicsContactWithBodies, EventListenerPhysicsContact, EventListenerTouchAllAtOnce, EventListenerCustom, EventListenerTouchOneByOne, EventListenerAssetsManagerEx, EventListenerFocus, EventListenerAcceleration, EventListenerController, EventListenerKeyboard, and EventListenerMouse.
Clones the listener, its subclasses have to override this method.
Implemented in EventListenerPhysicsContactWithGroup, EventListenerPhysicsContactWithShapes, EventListenerPhysicsContactWithBodies, EventListenerPhysicsContact, EventListenerTouchAllAtOnce, EventListenerCustom, EventListenerTouchOneByOne, EventListenerAssetsManagerEx, EventListenerFocus, EventListenerAcceleration, EventListenerController, EventListenerKeyboard, and EventListenerMouse.
Node* getAssociatedNode |
( |
| ) |
const |
|
inlineprotected |
Gets the node associated with this listener.
- Returns
- nullptr if it's a fixed priority listener, otherwise return non-nullptr
var getAssociatedNode |
( |
| ) |
|
|
inlineprotected |
Gets the node associated with this listener.
- Returns
- nullptr if it's a fixed priority listener, otherwise return non-nullptr
local getAssociatedNode |
( |
| ) |
|
|
inlineprotected |
Gets the node associated with this listener.
- Returns
- nullptr if it's a fixed priority listener, otherwise return non-nullptr
int getFixedPriority |
( |
| ) |
const |
|
inlineprotected |
Gets the fixed priority of this listener.
- Returns
- 0 if it's a scene graph priority listener, non-zero for fixed priority listener
Gets the fixed priority of this listener.
- Returns
- 0 if it's a scene graph priority listener, non-zero for fixed priority listener
local getFixedPriority |
( |
| ) |
|
|
inlineprotected |
Gets the fixed priority of this listener.
- Returns
- 0 if it's a scene graph priority listener, non-zero for fixed priority listener
Gets the listener ID of this listener When event is being dispatched, listener ID is used as key for searching listeners according to event type.
Gets the listener ID of this listener When event is being dispatched, listener ID is used as key for searching listeners according to event type.
Gets the listener ID of this listener When event is being dispatched, listener ID is used as key for searching listeners according to event type.
Gets the type of this listener.
- Note
- It's different from
EventType
, e.g. TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce
Gets the type of this listener.
- Note
- It's different from
EventType
, e.g. TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce
Gets the type of this listener.
- Note
- It's different from
EventType
, e.g. TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce
bool init |
( |
Type |
t, |
|
|
const ListenerID & |
listenerID, |
|
|
const std::function< void(Event *)> & |
callback |
|
) |
| |
Initializes event with type and callback function.
local init |
( |
local |
t, |
|
|
local |
listenerID, |
|
|
local |
callback |
|
) |
| |
Initializes event with type and callback function.
Checks whether the listener is enabled.
- Returns
- True if the listenrt is enabled.
Checks whether the listener is enabled.
- Returns
- True if the listenrt is enabled.
Checks whether the listener is enabled.
- Returns
- True if the listenrt is enabled.
Checks whether the listener is paused.
Checks whether the listener is paused.
Checks whether the listener is paused.
bool isRegistered |
( |
| ) |
const |
|
inlineprotected |
void setAssociatedNode |
( |
Node * |
node | ) |
|
|
inlineprotected |
Sets the node associated with this listener.
var setAssociatedNode |
( |
var |
node | ) |
|
|
inlineprotected |
Sets the node associated with this listener.
local setAssociatedNode |
( |
local |
node | ) |
|
|
inlineprotected |
Sets the node associated with this listener.
void setEnabled |
( |
bool |
enabled | ) |
|
|
inline |
Enables or disables the listener.
- Note
- Only listeners with
enabled
state will be able to receive events. When an listener was initialized, it's enabled by default. An event listener can receive events when it is enabled and is not paused. paused state is always false when it is a fixed priority listener.
- Parameters
-
enabled | True if enables the listener. |
var setEnabled |
( |
var |
enabled | ) |
|
|
inline |
Enables or disables the listener.
- Note
- Only listeners with
enabled
state will be able to receive events. When an listener was initialized, it's enabled by default. An event listener can receive events when it is enabled and is not paused. paused state is always false when it is a fixed priority listener.
- Parameters
-
enabled | True if enables the listener. |
local setEnabled |
( |
local |
enabled | ) |
|
|
inline |
Enables or disables the listener.
- Note
- Only listeners with
enabled
state will be able to receive events. When an listener was initialized, it's enabled by default. An event listener can receive events when it is enabled and is not paused. paused state is always false when it is a fixed priority listener.
- Parameters
-
enabled | True if enables the listener. |
void setFixedPriority |
( |
int |
fixedPriority | ) |
|
|
inlineprotected |
Sets the fixed priority for this listener.
- Note
- This method is only used for
fixed priority listeners
, it needs to access a non-zero value. 0 is reserved for scene graph priority listeners
var setFixedPriority |
( |
var |
fixedPriority | ) |
|
|
inlineprotected |
Sets the fixed priority for this listener.
- Note
- This method is only used for
fixed priority listeners
, it needs to access a non-zero value. 0 is reserved for scene graph priority listeners
local setFixedPriority |
( |
local |
fixedPriority | ) |
|
|
inlineprotected |
Sets the fixed priority for this listener.
- Note
- This method is only used for
fixed priority listeners
, it needs to access a non-zero value. 0 is reserved for scene graph priority listeners
void setPaused |
( |
bool |
paused | ) |
|
|
inlineprotected |
Sets paused state for the listener The paused state is only used for scene graph priority listeners.
EventDispatcher::resumeAllEventListenersForTarget(node)
will set the paused state to true
, while EventDispatcher::pauseAllEventListenersForTarget(node)
will set it to false
.
- Note
- 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events, call
setEnabled(false)
instead. 2) In Node
's onEnter and onExit, the paused state
of the listeners which associated with that node will be automatically updated.
var setPaused |
( |
var |
paused | ) |
|
|
inlineprotected |
Sets paused state for the listener The paused state is only used for scene graph priority listeners.
EventDispatcher::resumeAllEventListenersForTarget(node)
will set the paused state to true
, while EventDispatcher::pauseAllEventListenersForTarget(node)
will set it to false
.
- Note
- 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events, call
setEnabled(false)
instead. 2) In Node
's onEnter and onExit, the paused state
of the listeners which associated with that node will be automatically updated.
local setPaused |
( |
local |
paused | ) |
|
|
inlineprotected |
Sets paused state for the listener The paused state is only used for scene graph priority listeners.
EventDispatcher::resumeAllEventListenersForTarget(node)
will set the paused state to true
, while EventDispatcher::pauseAllEventListenersForTarget(node)
will set it to false
.
- Note
- 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events, call
setEnabled(false)
instead. 2) In Node
's onEnter and onExit, the paused state
of the listeners which associated with that node will be automatically updated.
void setRegistered |
( |
bool |
registered | ) |
|
|
inlineprotected |
var setRegistered |
( |
var |
registered | ) |
|
|
inlineprotected |
local setRegistered |
( |
local |
registered | ) |
|
|
inlineprotected |
Whether the listener has been added to dispatcher.
Whether the listener has been added to dispatcher.
Whether the listener has been added to dispatcher.
std::function<void(Event*)>
_onEvent |
|
protected |
The documentation for this class was generated from the following file: