Rumah  >  Artikel  >  pangkalan data  >  cocos2dx 3.1.1学习笔记 中文字符的使用

cocos2dx 3.1.1学习笔记 中文字符的使用

WBOY
WBOYasal
2016-06-07 15:49:47882semak imbas

这样使用时会出问题: auto label = Label::create(你好,fonts/3.ttf,28); 最好的解决办法是使用外置的xml文档/plist文档储存中文字符(必须使用UTF-8编码) 新建文档string.xml如下: ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC - //Apple//D

这样使用时会出问题:

      auto label = Label::create("你好","fonts/3.ttf",28);


最好的解决办法是使用外置的xml文档/plist文档储存中文字符(必须使用UTF-8编码)


新建文档string.xml如下:

 
br> //Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
 
 
    title  
    是男人就坚持20秒  
    new_game  
    新游戏  
    setting_game  
    设置  
    quit_game  
    退出  
    s  
    为什么这么难?!  
 


每个key对应一个string


在使用时:

        Dictionary* dictionary = Dictionary::createWithContentsOfFile("string.xml");
        CCString* str = (CCString*)dictionary->objectForKey("s");               //这里获取了字符串
        const char* s = str->getCString();                                                          //类型转换

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

也有这样使用的:

        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);



Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:cookie实现自动登陆(2)Artikel seterusnya:Oracle ACL(Access Control List)