Small man (Bill man) Personal Original, welcome to reprint, reprint please indicate the address, small man (Bill man) column address http://blog.csdn.net/bill_man
At this point, the test example of the cocos2d-x is almost introduced, and updates to this series of articles will be temporarily suspended, I will write a new example of cocos2d-x every week later (some of the game effects I write), so stay tuned. This article introduces some of the remaining tips.
1. Game Archive
The game archive is an indispensable part of the game, and the cocos2d-x engine has a very simple way to implement the archive ccuserdefault
Deposit: ccuserdefault: shareduserdefault ()-> setstringforkey ("uername", "bill_man ");
The first parameter is the key value, and the second parameter is the saved value. Other types of values can be saved, such
Get: ret = ccuserdefault: shareduserdefault ()-> getstringforkey ("uername ");
Cclog ("string is % s", Ret. c_str ());
The second line is to print the information with cclog, and there are methods to retrieve other types of values, such:
2. Switch to HD
With the improvement of hardware technology, a better picture is provided. We can use the following methods to switch
Ccdirector: shareddirector ()-> enableretinadisplay (true );
If the parameter is true, HD is enabled. If the parameter is false, HD is disabled. Of course, the current value is iPhone 4, itoumethane, and above, which supports the "retina" display. When you enable this function, your game images will automatically become "source image names (except for suffix +"-HD. "+ suffix). If the file does not exist, you will continue to use the source image.
3. Image Processing (anti-aliasing, minmap)
When we scale the image, we will always encounter distortion and sawtooth image, cocos2d-x support some ways to solve these problems
(1) added anti-aliasing to solve the Sawtooth problem during amplification.
On the left side of the page, it is normal, and the effect team ratio is normal. On the left side, use sprite-> gettexture ()-> setantialiastexparameters (); To achieve this. On the right side, use sprite2-> gettexture () -> setaliastexparameters ();
(2) Use minmap to reduce the validity period, and use minmap on the left.
Use the following method to generate minmap when defining a texture:
Then use the texture to declare the genie.
I just started to study this engine. If there are any errors, I hope you can correct them more,
This column has basically completed all the content. Thank you for your support and pay more attention to other columns after me.