您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/2/19 3:03:46发布12次查看
这样使用时会出问题: 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//enhttp://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);
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product