mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1923 from dumganhar/master
Updating doxygen comments for CCFileUtils.h.
This commit is contained in:
commit
fb1a32e696
|
@ -69,7 +69,7 @@ public:
|
|||
* @note It should be invoked after the resources were updated.
|
||||
* For instance, in the CocosPlayer sample, every time you run application from CocosBuilder,
|
||||
* All the resources will be downloaded to the writable folder, before new js app launchs,
|
||||
* this method should be invokded to clean the file searching cache.
|
||||
* this method should be invoked to clean the file search cache.
|
||||
*/
|
||||
void purgeCachedEntries();
|
||||
|
||||
|
@ -104,22 +104,47 @@ public:
|
|||
|
||||
/** Returns the fullpath for a given filename.
|
||||
|
||||
First it will try to get a new filename from the "filenameLookup" dictionary. If a new filename can't be found on the dictionary, it will use the original filename.
|
||||
Then it will try obtain the full path of the filename using the CCFileUtils search rules: resources directory
|
||||
First it will try to get a new filename from the "filenameLookup" dictionary.
|
||||
If a new filename can't be found on the dictionary, it will use the original filename.
|
||||
Then it will try to obtain the full path of the filename using the CCFileUtils search rules: resolutions, and search paths.
|
||||
The file search is based on the array element order of search paths and resolution directories.
|
||||
|
||||
If the filename can't be found on resource directory(e.g. Resources/iphone-hd), it will go back to the root of asset folder(e.g. Resources/) to find the filename.
|
||||
|
||||
If the filename can't be found on the file system, it will return the filename directly.
|
||||
For instance:
|
||||
|
||||
We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
|
||||
and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
|
||||
to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".
|
||||
|
||||
If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`.
|
||||
Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:
|
||||
|
||||
/mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/sprite.pvr.gz (if not found, return "sprite.png")
|
||||
|
||||
If the filename contains relative path like "gamescene/uilayer/sprite.png",
|
||||
and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`.
|
||||
The file search order will be:
|
||||
|
||||
/mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
|
||||
/mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
|
||||
internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png")
|
||||
|
||||
If the new file can't be found on the file system, it will return the parameter pszFileName directly.
|
||||
|
||||
This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable,
|
||||
you might need to load differerent resources for a given file in the different platforms.
|
||||
|
||||
Examples:
|
||||
|
||||
* In iOS: "image.png" -> "image.pvr.ccz" -> "searching path/resolution dir/image.pvr.ccz"
|
||||
* "gamescene/background.png" -> "gamescene/background.pvr.ccz" -> "searching path/gamescene/resolution dir/background.pvr.ccz"
|
||||
* In Android: "sounds/click.wav" -> "sounds/click.ogg" -> "searching path/sounds/resolution dir/click.ogg"
|
||||
|
||||
you might need to load different resources for a given file in the different platforms.
|
||||
|
||||
@since v2.1
|
||||
*/
|
||||
std::string fullPathForFilename(const char* pszFileName);
|
||||
|
@ -185,7 +210,7 @@ public:
|
|||
* Sets the array that contains the search order of the resources.
|
||||
*
|
||||
* @param searchResolutionsOrder The source array that contains the search order of the resources.
|
||||
* @see getSearchResolutionsOrder().
|
||||
* @see getSearchResolutionsOrder(), fullPathForFilename().
|
||||
* @since v2.1
|
||||
*/
|
||||
void setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder);
|
||||
|
@ -193,7 +218,7 @@ public:
|
|||
/**
|
||||
* Gets the array that contains the search order of the resources.
|
||||
*
|
||||
* @see setSearchResolutionsOrder().
|
||||
* @see setSearchResolutionsOrder(), fullPathForFilename().
|
||||
* @since v2.1
|
||||
*/
|
||||
const std::vector<std::string>& getSearchResolutionsOrder();
|
||||
|
@ -202,8 +227,16 @@ public:
|
|||
* Sets the array of search paths.
|
||||
* You can use this array to modify the search path of the resources.
|
||||
* If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.
|
||||
*
|
||||
* @param searchPaths
|
||||
*
|
||||
* @note This method could access relative path and absolute path.
|
||||
* If the relative path was passed to the vector, CCFileUtils will add the default resource directory before the relative path.
|
||||
* For instance:
|
||||
* On Android, the default resource root path is "assets/".
|
||||
* If "/mnt/sdcard/" and "resources-large" were set to the search paths vector,
|
||||
* "resources-large" will be converted to "assets/resources-large" since it was a relative path.
|
||||
*
|
||||
* @param searchPaths The array contains search paths.
|
||||
* @see fullPathForFilename()
|
||||
* @since v2.1
|
||||
*/
|
||||
void setSearchPaths(const std::vector<std::string>& searchPaths);
|
||||
|
@ -211,6 +244,8 @@ public:
|
|||
/**
|
||||
* Gets the array of search paths.
|
||||
*
|
||||
* @return The array of search paths.
|
||||
* @see fullPathForFilename().
|
||||
*/
|
||||
const std::vector<std::string>& getSearchPaths();
|
||||
|
||||
|
|
|
@ -38,27 +38,71 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
CCSize designSize = CCSizeMake(320, 480);
|
||||
CCSize resourceSize = CCSizeMake(320, 480);
|
||||
|
||||
vector<string> searchPath;
|
||||
std::vector<std::string> resDirOrders;
|
||||
|
||||
if (screenSize.height > 768)
|
||||
TargetPlatform platform = CCApplication::sharedApplication()->getTargetPlatform();
|
||||
if (platform == kTargetIphone || platform == kTargetIpad)
|
||||
{
|
||||
resourceSize = CCSizeMake(1536, 2048);
|
||||
searchPath.push_back("resources-ipadhd");
|
||||
if (screenSize.height > 1024)
|
||||
{
|
||||
resourceSize = CCSizeMake(1536, 2048);
|
||||
resDirOrders.push_back("resources-ipadhd");
|
||||
resDirOrders.push_back("resources-ipad");
|
||||
resDirOrders.push_back("resources-iphonehd");
|
||||
}
|
||||
else if (screenSize.height > 960)
|
||||
{
|
||||
resourceSize = CCSizeMake(768, 1024);
|
||||
resDirOrders.push_back("resources-ipad");
|
||||
resDirOrders.push_back("resources-iphonehd");
|
||||
}
|
||||
else if (screenSize.height > 480)
|
||||
{
|
||||
resourceSize = CCSizeMake(640, 960);
|
||||
resDirOrders.push_back("resources-iphonehd");
|
||||
resDirOrders.push_back("resources-iphone");
|
||||
}
|
||||
else
|
||||
{
|
||||
resourceSize = CCSizeMake(320, 480);
|
||||
resDirOrders.push_back("resources-iphone");
|
||||
}
|
||||
|
||||
}
|
||||
else if (screenSize.height > 640)
|
||||
else if (platform == kTargetAndroid || platform == kTargetWindows)
|
||||
{
|
||||
resourceSize = CCSizeMake(768, 1536);
|
||||
searchPath.push_back("resources-ipad");
|
||||
}
|
||||
else if (screenSize.height > 320)
|
||||
{
|
||||
resourceSize = CCSizeMake(640, 960);
|
||||
searchPath.push_back("resources-iphonehd");
|
||||
CCLOG("screen size [%f, %f]", screenSize.width, screenSize.height);
|
||||
if (screenSize.height > 960)
|
||||
{
|
||||
resourceSize = CCSizeMake(1280, 1920);
|
||||
resDirOrders.push_back("resources-xlarge");
|
||||
resDirOrders.push_back("resources-large");
|
||||
resDirOrders.push_back("resources-medium");
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
else if (screenSize.height > 720)
|
||||
{
|
||||
resourceSize = CCSizeMake(640, 960);
|
||||
resDirOrders.push_back("resources-large");
|
||||
resDirOrders.push_back("resources-medium");
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
else if (screenSize.height > 480)
|
||||
{
|
||||
resourceSize = CCSizeMake(480, 720);
|
||||
resDirOrders.push_back("resources-medium");
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
else
|
||||
{
|
||||
resourceSize = CCSizeMake(320, 480);
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
}
|
||||
|
||||
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
|
||||
CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(resDirOrders);
|
||||
|
||||
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
|
||||
pDirector->setContentScaleFactor(resourceSize.width/designSize.width);
|
||||
|
||||
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
COCOS2DX_ROOT="$DIR/../../../.."
|
||||
APP_ROOT="$DIR/.."
|
||||
APP_ANDROID_ROOT="$DIR"
|
||||
RESROUCE_ROOT="$APP_ROOT/../Shared/games/CocosDragonJS/Published files iOS"
|
||||
RESROUCE_ROOT="$APP_ROOT/../Shared/games/CocosDragonJS/Published files Android"
|
||||
BINDINGS_JS_ROOT="$APP_ROOT/../../../scripting/javascript/bindings/js"
|
||||
|
||||
echo
|
||||
|
|
|
@ -69,11 +69,14 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
{
|
||||
resourceSize = CCSizeMake(640, 960);
|
||||
resDirOrders.push_back("resources-large");
|
||||
resDirOrders.push_back("resources-medium");
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
else if (screenSize.height > 480)
|
||||
{
|
||||
resourceSize = CCSizeMake(480, 720);
|
||||
resDirOrders.push_back("resources-medium");
|
||||
resDirOrders.push_back("resources-small");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue