Cocos2d-x multi-resolution adaptation
from “Detailed explanation of Cocos2d-x Multi-resolution adaptation”
Cocos2d-iphone used point coordination with suffix like “-hd” to support retina iPhone. But this is not enough for the new iPhone 6 or 6+ and even for those Android devices.
“Design resolution” is newly evolved from the point coordination.
Resource resolution >> Design resolution >> Screen resolution
Resource resolution to Design resolution
API setContentScaleFactor() and setSearchPaths() control the conversion from resource resolution to design resolution.
Design resolution to Screen resolution
setDesignResolutionSize(DW, DH, resolutionPolicy) controls the conversion from design resolution to screen resolution.
Resolution policies
- kResolutionShowAll
- All the design area can display on screen, but may leave some area black on screen
- kResolutionExactFit
- Use different ratio for the height and width to fully fill the screen resolution even with image distortion
- kResolutionNoBorder
- kResolutionFixedHeight and kResolutionFixedWidth can replace this policy
- kResolutionFixedHeight &Â kResolutionFixedWidth
- Keep the height(width) of the design resolution, refine the width(height) of the design resolution according to the screen
Recommendation
- Portrait
- Set contentScaleFactor = RH/DH
- Use kResolutionFixedHeight policy
- Landscape
- Set contentScaleFactor = RW/DW
- Use kResolutionFixedWidth policy