本文整理汇总了C++中CCFileUtils::addSearchPath方法的典型用法代码示例。如果您正苦于以下问题:C++ CCFileUtils::addSearchPath方法的具体用法?C++ CCFileUtils::addSearchPath怎么用?C++ CCFileUtils::addSearchPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCFileUtils
的用法示例。
在下文中一共展示了CCFileUtils::addSearchPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// turn on display FPS
pDirector->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
pEGLView->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, kResolutionExactFit);
CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils();
fileUtils->addSearchPath("fonts");
fileUtils->addSearchPath("images");
fileUtils->addSearchPath("sounds");
CCScene* scene = CCScene::create();
GameScene* layer = GameScene::create();
scene->addChild(layer);
pDirector->runWithScene(scene);
return true;
}
示例2: initLuaGlobalVariables
void initLuaGlobalVariables(const std::string& entry)
{
//GLOBAL_ROOT_DIR
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCLuaStack* pStack = pEngine->getLuaStack();
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
using namespace std;
string path = pFileUtils->fullPathForFilename(entry.c_str());
// replace "\" with "/", normalize the path
int pos = string::npos;
while ((pos = path.find_first_of("\\")) != string::npos)
{
path.replace(pos, 1, "/");
}
string script_dir = path.substr(0, path.find_last_of("/"));
string root_dir = script_dir.substr(0, script_dir.find_last_of("/"));
CCLOG("RootDir: %s\nScriptDir: %s \n",root_dir.c_str(), script_dir.c_str());
std::string env = "GLOBAL_ROOT_DIR=\""; env.append(root_dir); env.append("\"");
pEngine->executeString(env.c_str());
env = "__LUA_STARTUP_FILE__=\"";env.append(path);env.append("\"");
pEngine->executeString(env.c_str());
pStack->addSearchPath(script_dir.c_str());
pFileUtils->addSearchPath(root_dir.c_str());
pFileUtils->addSearchPath(script_dir.c_str());
ScutExt::Init(root_dir+"/");
}