From: http://www.cnblogs.com/yangws/archive/2011/07/22/2114132.html
There is a headache with the development of games with Cocos2d-x, Android resolution is too much.
Although Android supports full screen, but because the length and width ratios of different screens are different, a game designed for a resolution may be increased or squashed on other mobile phones, which is very ugly.
The Cocos2d-x Provides proportional scaling that can be done without modifying the gameCodeThe game image is displayed on different mobile phones. However, due to the different aspect ratio, black borders may be left on both sides of the phone or on both sides of the phone.
The above two multi-resolution adaptation solutions both have disadvantages and are not very nice. So I personally copied a whole "Cocos2d-x full screen proportional scaling multi-resolution adaptation solution", wow click -- Take helloworld when the mouse ,:
This is the size of the game design, hvga, and the effect is perfect.
This is the effect on qvga, and the background image is slightly less displayed.
This is the effect on WVGA, and the background image is shown a little less.
The above effects maintain the aspect ratio in different resolutions, and achieve full screen effects in different resolutions. The UI elements such as blood strip and control bar are also kept in the screen area.
In fact, the method is very simple. Scale the image to cover the screen while maintaining the aspect ratio, and then use the code to obtain the coordinates of the eight vertices and center points at the intersection of the left and right sides and the oblique direction and the screen edge as the positioning point, all the UI elements such as blood strip are located on the Screen Based on 9 positioning points. In this way, you can.
The source code of the example is downloaded. The Code is based on cocos2d-1.0.0-x-0.9.0 and the engine is modified. For details, see readme.txt.