cocos2d-x  3.0alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NotificationCenter Class Reference

#include <CCNotificationCenter.h>

Inheritance diagram for NotificationCenter:
Object

Public Member Functions

 NotificationCenter ()
 NotificationCenter constructor. More...
 
 ~NotificationCenter ()
 NotificationCenter destructor. More...
 
void addObserver (Object *target, SEL_CallFuncO selector, const char *name, Object *sender)
 Adds an observer for the specified target. More...
 
void removeObserver (Object *target, const char *name)
 Removes the observer by the specified target and name. More...
 
int removeAllObservers (Object *target)
 Removes all notifications registered by this target. More...
 
void registerScriptObserver (Object *target, int handler, const char *name)
 Registers one hander for script binding. More...
 
var registerScriptObserver ( var target, var handler, var 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 (Object *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, Object *sender)
 Posts one notification event by name. More...
 
int getScriptHandler () const
 Gets script handler. More...
 
int getObserverHandlerByName (const char *name)
 Gets observer script handler. 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)

Static Public Member Functions

static NotificationCentergetInstance ()
 Gets the single instance of NotificationCenter. More...
 
local getInstance ()
 Gets the single instance of NotificationCenter. More...
 
static void destroyInstance ()
 Destroys the single instance of NotificationCenter. More...
 
static CC_DEPRECATED_ATTRIBUTE
NotificationCenter
sharedNotificationCenter (void)
local sharedNotificationCenter ()
static CC_DEPRECATED_ATTRIBUTE void purgeNotificationCenter (void)
local purgeNotificationCenter ()

Friends

class ScriptHandlerMgr

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 

Constructor & Destructor Documentation

var ctor ( )

NotificationCenter constructor.

local NotificationCenter ( )

NotificationCenter constructor.

Member Function Documentation

void addObserver ( Object target,
SEL_CallFuncO  selector,
const char *  name,
Object sender 
)

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.
senderThe object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. NULL means that the sender is not used to decide whether to deliver the notification to target.
var addObserver ( var  target,
var  selector,
var  name,
var  sender 
)

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.
senderThe object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. NULL means that the sender is not used to decide whether to deliver the notification to target.
local addObserver ( local  target,
local  selector,
local  name,
local  sender 
)

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.
senderThe object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. NULL means that the sender is not used to decide whether to deliver the notification to target.
static void destroyInstance ( )
static

Destroys the single instance of NotificationCenter.

var destroyInstance ( )
static

Destroys the single instance of NotificationCenter.

local destroyInstance ( )
static

Destroys the single instance of NotificationCenter.

static NotificationCenter*
getInstance
( )
static

Gets the single instance of NotificationCenter.

var getInstance ( )
static

Gets the single instance of NotificationCenter.

local getInstance ( )
static

Gets the single instance of NotificationCenter.

int getObserverHandlerByName ( const char *  name)

Gets observer script handler.

Parameters
nameThe name of this notification.
Returns
The observer script handle.
var getObserverHandlerByName ( var  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 ( ) const
inline

Gets script handler.

Note
Only supports Lua Binding now.
Returns
The script handle.
var 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.
var postNotification ( var  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,
Object sender 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
senderThe object posting the notification. Can be NULL
var postNotification ( var  name,
var  sender 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
senderThe object posting the notification. Can be NULL
local postNotification ( local  name,
local  sender 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
senderThe object posting the notification. Can be NULL
static CC_DEPRECATED_ATTRIBUTE
void purgeNotificationCenter
( void  )
static
var purgeNotificationCenter (   )
static
local purgeNotificationCenter (   )
static
void registerScriptObserver ( Object target,
int  handler,
const char *  name 
)

Registers one hander for script binding.

Note
Only supports Lua Binding now.
Parameters
handlerThe lua handler.
var registerScriptObserver ( var  target,
var  handler,
var  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 ( Object target)

Removes all notifications registered by this target.

Parameters
targetThe target of this notification.
Returns
the number of observers removed
var removeAllObservers ( var  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 ( Object target,
const char *  name 
)

Removes the observer by the specified target and name.

Parameters
targetThe target of this notification.
nameThe name of this notification.
var removeObserver ( var  target,
var  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 CC_DEPRECATED_ATTRIBUTE
NotificationCenter*
sharedNotificationCenter
( void  )
static
var sharedNotificationCenter (   )
static
local sharedNotificationCenter (   )
static
void unregisterScriptObserver ( Object target,
const char *  name 
)

Unregisters script observer.

var unregisterScriptObserver ( var  target,
var  name 
)

Unregisters script observer.

local unregisterScriptObserver ( local  target,
local  name 
)

Unregisters script observer.

Friends And Related Function Documentation

friend class ScriptHandlerMgr
friend
var ScriptHandlerMgr
friend
local ScriptHandlerMgr
friend

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