cocos2dx java 乱码_Cocos2dx 中文乱码问题解决办法

#include "HelloWorldScene.h"

USING_NS_CC;

CCScene* HelloWorld::scene()

// 'scene' is an autorelease object

CCScene *scene = CCScene::create();

// 'layer' is an autorelease object

HelloWorld *layer = HelloWorld::create();

// add layer as a child to scene

scene->addChild(layer);

// return the scene

return scene;

// on "init" you need to initialize your instance

bool HelloWorld::init()

//利用CCDictionary来读取xml

CCDictionary *strings = CCDictionary::createWithContentsOfFile("strings.xml");//载入资源文件夹的strings.xml

//读取HelloWorld键中的值objectForKey根据key,获取对应的string

const char *HelloWorld = ((CCString*)strings->objectForKey("HelloWorldString"))->m_sString.c_str();

//获取屏幕的尺寸、位置信息等

CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

//乱码文字

CCLabelTTF *label0 = CCLabelTTF::create("你好,世界","arial",72);

label0->setPosition(ccp(visibleSize.width/2,2*visibleSize.height/3));

this->addChild(label0);

//正常中文

CCLabelTTF *label1 = CCLabelTTF::create(HelloWorld,"arial",72);

label1->setPosition(ccp(visibleSize.width/2,visibleSize.height/3));

this->addChild(label1);

return true;

void HelloWorld::menuCloseCallback(CCObject* pSender)

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)

CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");

#else

CCDirector::sharedDirector()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

exit(0);

#endif

#endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值