Hi!
I simply do not understand ResolutionPolicy and searchPaths.
- I know that you can load resources matching the given device using searchpaths and yea this can save you from have to scale the image with different values for x and y. Let’s say that the target was IOS so I would have the following folders, “iPhone5”, “iPhone4”, “iPhoneRetina”, “ipad”, “ipadRetina”. Then I would have to load these depending on the resolution and this could be done like this I guess:
// if the device is iPad
if (screenSize.height >= 2048) {
searchPaths.push_back("ipadRetina");
}
// if the device is iPhone
else{
// for retina iPhone
if (screenSize.height > 320) {
searchPaths.push_back("iPhone4");
}
}
etc... Just a random example
But how does this work? Let’s imagine that I have the image “image.png” in each of these folders and then I would create a sprite consisting of that image. Would the engine then find “image.png” in the folder given by the searchPath?
And when distributing the app, does all the resources from all the folders get compiled with the app because then I do not know if it is worth it avoiding some stretching compared the amount of extra size generated from all the resources. I mean why not then just have one bigger image that you would stretch according to the screen size?
2 . When doing something like this // Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
I do not understand the part ResolutionPolicy even though I have read about it in the documentation. I do not see what you can achieve using these that the usage of searchPaths would make sure that all the images are fitting the screen perfectly. So could anybody tell me if I just have misunderstood the concept of this? Like the policy NO_BORDER, what is its purpose when the developer probably just wants to use all the screen size anyway and therefore makes sure that the resources either will be scaled to exact fit the screen or using seachPaths to load the right resouces?
3 . I went to this link https://www.raywenderlich.com/48180/cocos2d-x-tutorial-making-a-universal-app-part-1 and he has made a folder called “hd” and a folder called “sd”. The “hd” folder contains larger images than the “sd” folder and so he does this:
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);
That made me more confused… Why is he adding both the “hd” AND the “sd” folder to the ipad and iphone-retina section? Isn’t the point to make link the one correct folder containing the resources for the certain resolution?
I hope you understand my questions, at least you should be able to understand that I am a confused man However, I do not really have time to analyze the text for missing links in the plot but you should get the main idea
Somebody out there, please explain all this! Thanks! Much appreciated.