Multi-Resolution confusing->

Multi-Resolution confusing->
0.0 0

#1

Hi!
I simply do not understand ResolutionPolicy and searchPaths.

  1. 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? :sob:

I hope you understand my questions, at least you should be able to understand that I am a confused man :wink: However, I do not really have time to analyze the text for missing links in the plot but you should get the main idea :slight_smile:
Somebody out there, please explain all this! Thanks! Much appreciated.


#2

Hi,

By default I think it sux :smiley:

Just in case you need SD, HD and HDR files :slight_smile: good luck! :smiley:


#4

AFAIR you can add multiple paths. First ones added have higher priority when searching assets. In Ray’s case if there are HD asset then it will be used, otherwise the one from SD folder will be used.


#5

Okay, thank you. But not then just use the “HD” assets instead of then both since you got simply scale the images down to half in order to achieve the exact same thing right? Is there some sort of advantage of doing like he does or?


#6

Low end devices have not so much memory to be able keep many big (hi-res) images.
Second scenario:
If you have many heavy backgrounds which are still looking good when upscaled then you could store them in low-res quality and put them in SD folder. Then in your game you scale them up, so they take the entire screen. Thus your game size (ipa or apk) will be smaller. To scale big sprites and avoid performance hit look here [SOLVED] How to really resize a Sprite (to avoid scaling it)


#7

Everybody is more than welcome to answer my questions. :relieved:


#8

I check the screen size. Based upon this I decide which assets to use and also set a scale factor multiplier. These are items I use when making decisions. Example. On an iPad Pro I use my best quality assets and my scale factor is higher so fonts and spaces etc are larger.


#9

Well okay then. Could you also answer this then:

Thanks. Much appreciated


#10

And i am still wondering a lot about this: [quote=“nichlaspro132, post:1, topic:34889”]
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?
[/quote]


#11

ResolutionPolicy answers the question “what should cocos2dx do when the ratio of your design resolution is not equal the ratio of the physical device’s screen”. Cocos can crop your game, distort(if you want exact fit), show borders or put extra pixels at your disposal.
You should make some tests to better realize the difference.


#12

I did my best to write the definitive guide on the best scaling and multi-res solution using cocos2d-x, including animations and code examples. Here:

http://blog.6x13.com/2d-asset-scaling-resolution/


#13

That’s funny. Your blog post was show within my Google Now recommendations yesterday.


#14

Wow! I didn’t even know there is a Google Now, but I am grateful it reads my posts :smile: