位置: 编程技术 - 正文
推荐整理分享cocos2dx3.3显示中文(cocos设置中文),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:cocos onload,cocos2dx怎么打开,cocos2d schedule,cocos2dx schedule,cocos creator loading,cocos loading,cocos creator loading,cocos2dx schedule,内容如对您有帮助,希望把文章链接给更多的朋友!
参考: __ChineseString_H__ #define __ChineseString_H__ #include "cocos2d.h"#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN)#include "..cocos2dexternalwin-specificiconincludeiconv.h"#endif#pragma comment(lib,"libiconv.lib")#include "string"using namespace std;static char g_GBKConvUTF8Buf[] = { 0 };class ChineseString{public:static const char* GBKToUTF8(const char *strChar)//将字符串转成UFT-8 {iconv_t iconvH = iconv_open("utf-8", "gb");if (iconvH == 0){return NULL;}size_t strLength = strlen(strChar);size_t outLength = strLength * 4;size_t copyLength = outLength;memset(g_GBKConvUTF8Buf, 0, );char* outbuf = (char*)malloc(outLength);char* pBuff = outbuf;memset(outbuf, 0, outLength);if (-1 == iconv(iconvH, &strChar, &strLength, &outbuf, &outLength)){iconv_close(iconvH);return NULL;}memcpy(g_GBKConvUTF8Buf, pBuff, copyLength);free(pBuff);iconv_close(iconvH);return g_GBKConvUTF8Buf;}};#endif
如何调用:
Label *lb = Label::create(ChineseString::GBKToUTF8("字幕滚动应该是要在一个范围内可见的nnn摇杆背景!!"), "", );lb->setPosition(visibleSize / 2);lb->setDimensions(, );this->addChild(lb);
cocos2dx之如何优化内存使用 内存优化原则为了优化应用内存,你应该知道是什么消耗了你应用的大部分内存,答案就是Texture(纹理)!它几乎占据了%的应用内存。那么我们应该
关于Cocos2dx的游戏暂停方法 开始用CCDirector::sharedirector()-pause();这句话是必然的、但是用了之后按钮的触发还是会生效。查看了一些案例有人说把所有button事件取消。也有注意说把
cocos2dx ios 视频播放器 2.x到3.x版本都可以使用 在cocos2dx版本中使用视频播放器的话需要以下步骤1、在写一个.mm的文件我这里的mm叫IOSPlayVedio这个头文件定义这个staticvoidplayOnLineVideo4IOS(char*pszVideoUrl);.mm
标签: cocos设置中文
本文链接地址:https://www.jiuchutong.com/biancheng/372757.html 转载请保留说明!上一篇:cocos2dx 3.4版本直接运行exe 不能运行bug(cocos2dx 4.0更新内容)
下一篇:cocos2dx之如何优化内存使用(cocos2dx引擎优化)
友情链接: 武汉网站建设