cocos2d-x  2.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCNotificationCenter Class Reference

#include <CCNotificationCenter.h>

Inheritance diagram for CCNotificationCenter:
CCObject CCCopying

Public Member Functions

 CCNotificationCenter ()
 ~CCNotificationCenter ()
 CCNotificationCenter destructor. More...
 
void addObserver (CCObject *target, SEL_CallFuncO selector, const char *name, CCObject *obj)
 Adds an observer for the specified target. More...
 
void removeObserver (CCObject *target, const char *name)
 Removes the observer by the specified target and name. More...
 
int removeAllObservers (CCObject *target)
 Removes all notifications registered by this target. More...
 
void registerScriptObserver (CCObject *target, int handler, const char *name)
 Registers one hander for script binding. More...
 
local registerScriptObserver ( local target, local handler, local name)
 Registers one hander for script binding. More...
 
void unregisterScriptObserver (CCObject *target, const char *name)
 Unregisters script observer. More...
 
void postNotification (const char *name)
 Posts one notification event by name. More...
 
void postNotification (const char *name, CCObject *object)
 Posts one notification event by name. More...
 
int getScriptHandler ()
 Gets script handler. More...
 
int getObserverHandlerByName (const char *name)
 Gets observer script handler. More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Static Public Member Functions

static CCNotificationCentersharedNotificationCenter (void)
 Gets the single instance of CCNotificationCenter. More...
 
static void purgeNotificationCenter (void)
 Destroys the single instance of CCNotificationCenter. More...
 

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Constructor & Destructor Documentation

Member Function Documentation

void addObserver ( CCObject target,
SEL_CallFuncO  selector,
const char *  name,
CCObject obj 
)

Adds an observer for the specified target.

Parameters
targetThe target which wants to observe notification events.
selectorThe callback function which will be invoked when the specified notification event was posted.
nameThe name of this notification.
objThe extra parameter which will be passed to the callback function.
local addObserver ( local  target,
local  selector,
local  name,
local  obj 
)

Adds an observer for the specified target.

Parameters
targetThe target which wants to observe notification events.
selectorThe callback function which will be invoked when the specified notification event was posted.
nameThe name of this notification.
objThe extra parameter which will be passed to the callback function.
int getObserverHandlerByName ( const char *  name)

Gets observer script handler.

Parameters
nameThe name of this notification.
Returns
The observer script handle.
local getObserverHandlerByName ( local  name)

Gets observer script handler.

Parameters
nameThe name of this notification.
Returns
The observer script handle.
int getScriptHandler ( )
inline

Gets script handler.

Note
Only supports Lua Binding now.
Returns
The script handle.
local getScriptHandler ( )
inline

Gets script handler.

Note
Only supports Lua Binding now.
Returns
The script handle.
void postNotification ( const char *  name)

Posts one notification event by name.

Parameters
nameThe name of this notification.
local postNotification ( local  name)

Posts one notification event by name.

Parameters
nameThe name of this notification.
void postNotification ( const char *  name,
CCObject object 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
objectThe extra parameter.
local postNotification ( local  name,
local  object 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
objectThe extra parameter.
static void purgeNotificationCenter ( void  )
static

Destroys the single instance of CCNotificationCenter.

local purgeNotificationCenter (   )
static

Destroys the single instance of CCNotificationCenter.

void registerScriptObserver ( CCObject target,
int  handler,
const char *  name 
)

Registers one hander for script binding.

Note
Only supports Lua Binding now.
Parameters
handlerThe lua handler.
local registerScriptObserver ( local  target,
local  handler,
local  name 
)

Registers one hander for script binding.

Note
Only supports Lua Binding now.
Parameters
handlerThe lua handler.
int removeAllObservers ( CCObject target)

Removes all notifications registered by this target.

Parameters
targetThe target of this notification.
Returns
the number of observers removed
local removeAllObservers ( local  target)

Removes all notifications registered by this target.

Parameters
targetThe target of this notification.
Returns
the number of observers removed
void removeObserver ( CCObject target,
const char *  name 
)

Removes the observer by the specified target and name.

Parameters
targetThe target of this notification.
nameThe name of this notification.
local removeObserver ( local  target,
local  name 
)

Removes the observer by the specified target and name.

Parameters
targetThe target of this notification.
nameThe name of this notification.
static CCNotificationCenter*
sharedNotificationCenter
( void  )
static

Gets the single instance of CCNotificationCenter.

local sharedNotificationCenter (   )
static

Gets the single instance of CCNotificationCenter.

void unregisterScriptObserver ( CCObject target,
const char *  name 
)

Unregisters script observer.

local unregisterScriptObserver ( local  target,
local  name 
)

Unregisters script observer.


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