您的位置:首页 > 移动开发 > Cocos引擎

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

2014-05-08 17:59 423 查看

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*);


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: