Cocos2dx3.1.1 use of Chinese Characters in study notes

Source: Internet
Author: User
In this case, problems occur: autolabelLabel: create (hello, fonts3.ttf, 28); the best solution is to store Chinese characters using an external xml document plist document (UTF-8 encoding is required) create document string. xml is as follows :? Xmlversion1.0encodingUTF-8 ?! DOCTYPEplistPUBLIC

In this case, problems will occur: auto label = Label: create (hello, fonts/3.ttf, 28 ); the best solution is to use an external xml document/plist document to store Chinese characters (must be encoded using a UTF-8) to create a document string. xml is as follows :? Xml version = 1.0 encoding = UTF-8? ! DOCTYPE plist PUBLIC-// Apple // D

In this way, problems may occur:

Auto label = Label: create ("hello", "fonts/3.ttf", 28 );


The best solution is to store Chinese characters using external xml documents/plist documents (must be UTF-8 encoded)


The new document string. xml is as follows:


// Apple // dtd plist 1.0 // EN "" http://www.apple.com/DTDs/PropertyList-1.0.dtd ">


Title
20 seconds for a man
New_game
New game
Setting_game
Set
Quit_game
Exit
S
Why is it so difficult ?!



Each key corresponds to a string


In use:

Dictionary * dictionary = Dictionary: createWithContentsOfFile ("string. xml ");
CCString * str = (CCString *) dictionary-> objectForKey ("s"); // the string is obtained here.
Const char * s = str-> getCString (); // type conversion

Auto label = Label: create (s, "fonts/3.ttf", 28 );

It is also used as follows:

TTFConfig ttfConfig ("fonts/3.ttf", 28, GlyphCollection: CUSTOM );
Dictionary * dictionary = Dictionary: createWithContentsOfFile ("fonts/string. xml ");
CCString * str = (CCString *) dictionary-> objectForKey ("s ");
Const char * s = str-> getCString ();

Label * label = Label: createWithTTF (ttfConfig, s, TextHAlignment: CENTER );

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.