[ios5 cocos2d游戏开发实战] 笔记3-FileUtils, notificationCenter

FileUtils

//文件管理工具
FileUtils::getInstance()
std::string getStringFromFile(const std::string& filename);//读取文件中的字符串
Data getDataFromFile(const std::string& filename);//获取文件数据
void setSearchPaths(const std::vector<std::string>& searchPaths);//设置搜索路径
void addSearchPath(const std::string & path);//增加搜索路径
bool isFileExist(const std::string& filePath);//判断文件是否存在

NotificationCenter

//发送事件
CCNotificationCenter::sharedNotificationCenter()->postNotification(CLICK_TEST_MSG, (CCObject*)data);

//监听事件
void GameManager::initListener()
{
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(GameManager::onClickTest), CLICK_TEST_MSG, NULL);
}

//处理事件
void GameManager::onClickTest(CCObject* obj)
{
    CCMessageBox("onClickTest", "Title");

    //移除监听事件
    CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, CLICK_TEST_MSG);
}
typedef void (CCObject::*SEL_SCHEDULE)(float);// 用来调update  
typedef void (CCObject::*SEL_CallFunc)();// 用来自定义无参回调  
typedef void (CCObject::*SEL_CallFuncN)(CCNode*);// 带执行者回调  
typedef void (CCObject::*SEL_CallFuncND)(CCNode*, void*); // 带一个自定参数的回调  
typedef void (CCObject::*SEL_CallFuncO)(CCObject*);  
typedef void (CCObject::*SEL_MenuHandler)(CCObject*);  
typedef void (CCObject::*SEL_EventHandler)(CCEvent*);  
typedef int (CCObject::*SEL_Compare)(CCObject*); 

 

原文地址:https://www.cnblogs.com/zengyou/p/3716736.html