本文整理汇总了C++中CCFileUtils::setSearchPaths方法的典型用法代码示例。如果您正苦于以下问题:C++ CCFileUtils::setSearchPaths方法的具体用法?C++ CCFileUtils::setSearchPaths怎么用?C++ CCFileUtils::setSearchPaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCFileUtils
的用法示例。
在下文中一共展示了CCFileUtils::setSearchPaths方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
void TestResolutionDirectories::onEnter()
{
FileUtilsDemo::onEnter();
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
string ret;
sharedFileUtils->purgeCachedEntries();
m_defaultSearchPathArray = sharedFileUtils->getSearchPaths();
vector<string> searchPaths = m_defaultSearchPathArray;
searchPaths.insert(searchPaths.begin(), "Misc");
sharedFileUtils->setSearchPaths(searchPaths);
m_defaultResolutionsOrderArray = sharedFileUtils->getSearchResolutionsOrder();
vector<string> resolutionsOrder = m_defaultResolutionsOrderArray;
resolutionsOrder.insert(resolutionsOrder.begin(), "resources-ipadhd");
resolutionsOrder.insert(resolutionsOrder.begin()+1, "resources-ipad");
resolutionsOrder.insert(resolutionsOrder.begin()+2, "resources-widehd");
resolutionsOrder.insert(resolutionsOrder.begin()+3, "resources-wide");
resolutionsOrder.insert(resolutionsOrder.begin()+4, "resources-hd");
resolutionsOrder.insert(resolutionsOrder.begin()+5, "resources-iphone");
sharedFileUtils->setSearchResolutionsOrder(resolutionsOrder);
for( int i=1; i<7; i++) {
CCString *filename = CCString::createWithFormat("test%d.txt", i);
ret = sharedFileUtils->fullPathForFilename(filename->getCString());
CCLog("%s -> %s", filename->getCString(), ret.c_str());
}
}
示例2: onExit
void TestSearchPath::onExit()
{
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
// reset search path
sharedFileUtils->setSearchPaths(m_defaultSearchPathArray);
sharedFileUtils->setSearchResolutionsOrder(m_defaultResolutionsOrderArray);
FileUtilsDemo::onExit();
}
示例3: setResourceRootPath
void CCApplication::setResourceRootPath(const std::string& rootResDir)
{
m_resourceRootPath = rootResDir;
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/')
{
m_resourceRootPath += '/';
}
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
pFileUtils->setSearchPaths(searchPaths);
}
示例4:
XFileAssist::XFileAssist()
{
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::string strWritePath = pFileUtils->getWritablePath();
std::vector<std::string> pathTable;
pathTable.push_back(strWritePath);
pFileUtils->setSearchPaths(pathTable);
}
示例5: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// As an example, load config file
// XXX: This should be loaded before the Director is initialized,
// XXX: but at this point, the director is already initialized
CCConfiguration::sharedConfiguration()->loadConfigFile("configs/config-example.plist");
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
CCSize designSize = CCSizeMake(480, 320);
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths;
if (screenSize.height > 320)
{
CCSize resourceSize = CCSizeMake(960, 640);
searchPaths.push_back("hd");
searchPaths.push_back("hd/scenetest");
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}
else
{
searchPaths.push_back("scenetest");
}
pFileUtils->setSearchPaths(searchPaths);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
#else
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
#endif
CCScene * pScene = CCScene::create();
CCLayer * pLayer = new TestController();
pLayer->autorelease();
pScene->addChild(pLayer);
pDirector->runWithScene(pScene);
return true;
}
示例6: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
CCSize designSize = CCSizeMake(480, 320);
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
if (screenSize.height > 320)
{
CCSize resourceSize = CCSizeMake(960, 640);
std::vector<std::string> searchPaths;
searchPaths.push_back("hd");
pFileUtils->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
// turn on display FPS
// pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
// CCScene *pScene = HelloWorld::scene();
CocosGUIExamplesRegisterScene *pScene = new CocosGUIExamplesRegisterScene();
pScene->autorelease();
// run
pDirector->runWithScene(pScene);
return true;
}
示例7: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
#ifdef TIZEN
CCSize designSize = CCSizeMake(1280, 720);
#else
CCSize designSize = CCSizeMake(480, 320);
#endif
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
if (screenSize.height > 320)
{
CCSize resourceSize = CCSizeMake(960, 640);
std::vector<std::string> searchPaths;
searchPaths.push_back("hd");
pFileUtils->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
CCScene * pScene = CCScene::create();
CCLayer * pLayer = new TestController();
pLayer->autorelease();
pScene->addChild(pLayer);
pDirector->runWithScene(pScene);
return true;
}
示例8: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
CCFileUtils *pFileUtils = CCFileUtils::sharedFileUtils();
std::vector<std::string> searchPaths;
CCSize designSize = CCSizeMake(480, 320);
CCSize resourceSize;
// if the device is iPad
if (screenSize.height >= 768) {
searchPaths.push_back("hd");
searchPaths.push_back("sd");
resourceSize = CCSizeMake(1024, 768);
designSize = CCSizeMake(1024, 768);
}
// if the device is iPhone
else{
// for retina iPhone
if (screenSize.height > 320) {
searchPaths.push_back("hd");
searchPaths.push_back("sd");
resourceSize = CCSizeMake(960, 640);
}
else{
searchPaths.push_back("sd");
resourceSize = CCSizeMake(480, 320);
}
}
searchPaths.push_back("WhackAMoleSounds");
pFileUtils->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(resourceSize.width / designSize.width);
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionFixedWidth);
// load background and foreground
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("background.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("foreground.plist");
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}