Study Notes on cocos2d-x (26)-others (game archival, switching to HD, image processing)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.