1 | //发送事件 |
02 | CCNotificationCenter::sharedNotificationCenter()->postNotification(CLICK_TEST_MSG, (CCObject*)data); |
03 |
04 | //监听事件 |
05 | void GameManager::initListener() |
06 | { |
07 | CCNotificationCenter::sharedNotificationCenter()->addObserver( this , callfuncO_selector(GameManager::onClickTest), CLICK_TEST_MSG, NULL); |
08 | } |
09 |
10 | //处理事件 |
11 | void GameManager::onClickTest(CCObject* obj) |
12 | { |
13 | CCMessageBox( "onClickTest" , "Title" ); |
14 |
15 | //移除监听事件 |
16 | CCNotificationCenter::sharedNotificationCenter()->removeObserver( this , CLICK_TEST_MSG); |
17 | } |