0
我是Cocos2d-X的新手。通过CCNotficationCenter传递数据
CCNotificationCenter::sharedNotificationCenter()->addObserver(
this,
callfuncO_selector(test::printSomething),
"hello",
NULL);
和回调函数是
void PingoScreen::printSomething(CCObject *pObject) {
CCString * myData = (CCString*)pObject;
CCLog("The data posted is %s",myData);
}
现在我想通过通知发送CCString参数,以便
CCNotificationCenter::sharedNotificationCenter()->postNotification("hello",
ccs(notificationData));
我怎样才能做到这一点?通知定义中需要更改什么?
是什么最后的NULL意味着在注册通知码? – AndroidDev
addObserver中的额外对象参数用作过滤器。如果设置为对象,则只有由此发件人发送的通知才会传送给观察者。如果设置为NULL,则此类型的所有通知将传递给观察者。 – nomann