cocos2d-x  3.0-alpha0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EventListener Class Referenceabstract

The base class of event listener. More...

#include <CCEventListener.h>

Inheritance diagram for EventListener:
Object EventListenerAcceleration EventListenerCustom EventListenerKeyboard EventListenerTouch

Public Member Functions

virtual ~EventListener ()
 Destructor. More...
 
virtual bool checkAvaiable ()=0
 Checks whether the listener is available. More...
 
virtual EventListenerclone ()=0
 Clones the listener, its subclasses have to override this method. More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual void update (float dt)

Protected Member Functions

 EventListener ()
 Constructor. More...
 
 EventListener ()
 Constructor. More...
 
bool init (const std::string &t, std::function< void(Event *)>callback)
 Initializes event with type and callback function. More...
 
local init ( local t, local callback)
 Initializes event with type and callback function. More...
 

Protected Attributes

std::function< void(Event *)> _onEvent
local _onEvent
std::string _type
 Event callback function. More...
 
var _type
 Event callback function. More...
 
local _type
 Event callback function. More...
 
bool _isRegistered
 Event type. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
var _reference
 count of references More...
 
local _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 
var _autoReleaseCount
 count of autorelease More...
 
local _autoReleaseCount
 count of autorelease More...
 

Friends

class EventDispatcher
 Whether the listener has been added to dispatcher. More...
 
class Node

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

Detailed Description

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 AccelerationEventListener, KeyboardEventListener or TouchEventListener, CustomEventListener.

Constructor & Destructor Documentation

EventListener ( )
protected

Constructor.

var EventListener ( )
protected

Constructor.

local EventListener ( )
protected

Constructor.

virtual ~EventListener ( )
virtual

Destructor.

var ~EventListener ( )
virtual

Destructor.

local ~EventListener ( )
virtual

Destructor.

Member Function Documentation

virtual bool checkAvaiable ( )
pure virtual

Checks whether the listener is available.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

var checkAvaiable ( )
pure virtual

Checks whether the listener is available.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

local checkAvaiable ( )
pure virtual

Checks whether the listener is available.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

virtual EventListener* clone ( )
pure virtual

Clones the listener, its subclasses have to override this method.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

var clone ( )
pure virtual

Clones the listener, its subclasses have to override this method.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

local clone ( )
pure virtual

Clones the listener, its subclasses have to override this method.

Implemented in EventListenerCustom, EventListenerKeyboard, EventListenerTouch, and EventListenerAcceleration.

bool init ( const std::string &  t,
std::function< void(Event *)>  callback 
)
protected

Initializes event with type and callback function.

var init ( var  t,
var  callback 
)
protected

Initializes event with type and callback function.

local init ( local  t,
local  callback 
)
protected

Initializes event with type and callback function.

Friends And Related Function Documentation

friend class EventDispatcher
friend

Whether the listener has been added to dispatcher.

var EventDispatcher
friend

Whether the listener has been added to dispatcher.

local EventDispatcher
friend

Whether the listener has been added to dispatcher.

friend class Node
friend
var Node
friend
local Node
friend

Member Data Documentation

bool _isRegistered
protected

Event type.

var _isRegistered
protected

Event type.

local _isRegistered
protected

Event type.

std::function<void(Event*)>
_onEvent
protected
var _onEvent
protected
local _onEvent
protected
std::string _type
protected

Event callback function.

var _type
protected

Event callback function.

local _type
protected

Event callback function.


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