#include "HelloWorldScene.h"
#include "iconv\iconv.h"
#include "Tools.h"
using namespace cocos2d;
CCScene* HelloWorld::scene()
{
CCScene * scene = NULL;
do
{
// 'scene' is an autorelease object
scene = CCScene::create();
CC_BREAK_IF(! scene);
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
CC_BREAK_IF(! layer);
// add layer as a child to scene
scene->addChild(layer);
} while (0);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
// //////////////////////////////////////////////////////////////////////////
// // super init first
// //////////////////////////////////////////////////////////////////////////
// CC_BREAK_IF(! CCLayer::init());
// //////////////////////////////////////////////////////////////////////////
// // add your codes below...
// //////////////////////////////////////////////////////////////////////////
// // 1. Add a menu item with "X" image, which is clicked to quit the program.
// // Create a "close" menu item with close icon, it's an auto release object.
// CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
// "CloseNormal.png",
// "CloseSelected.png",
// this,
// menu_selector(HelloWorld::menuCloseCallback));
// CC_BREAK_IF(! pCloseItem);
// // Place the menu item bottom-right conner.
// pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));
// // Create a menu with the "close" menu item, it's an auto release object.
// CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
// pMenu->setPosition(CCPointZero);
// CC_BREAK_IF(! pMenu);
// // Add the menu to HelloWorld layer as a child layer.
// this->addChild(pMenu, 1);
// // 2. Add a label shows "Hello World".
// // Create a label and initialize with string "Hello World".
// CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
// CC_BREAK_IF(! pLabel);
// // Get window size and place the label upper.
CCSize size = CCDirector::sharedDirector()->getWinSize();
// pLabel->setPosition(ccp(size.width / 2, size.height - 50));
// // Add the label to HelloWorld layer as a child layer.
// this->addChild(pLabel, 1);
// // 3. Add add a splash screen, show the cocos2d splash image.
// CCSprite* pSprite = CCSprite::create("HelloWorld.png");
// CC_BREAK_IF(! pSprite);
// // Place the sprite on the center of the screen
// pSprite->setPosition(ccp(size.width/2, size.height/2));
// // Add the sprite to HelloWorld layer as a child layer.
// this->addChild(pSprite, 0);
//第一种方式:
/*std::string china="中文!哈哈";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
GBKToUTF8(china,"gbk","utf-8");
#endif
CCMenuItem *chinaItem = CCMenuItemFont::create(china.c_str(),this,NULL);
chinaItem->setPosition(ccp(size.width/2,size.height/2));
this->addChild(chinaItem);*/
//第二种方式:
CCSize s = CCDirector::sharedDirector()->getWinSize();
//利用CCDictionary来读取xml
CCDictionary *strings = CCDictionary::create("fonts/strings.xml");
//中文,日语,西班牙语:objectForKey根据key,获取对应的string
const char *chinese = ((CCString*)strings->objectForKey("chinese1"))->m_sString.c_str();
const char *japanese = ((CCString*)strings->objectForKey("japanese"))->m_sString.c_str();
const char *spanish = ((CCString*)strings->objectForKey("spanish"))->m_sString.c_str();
CCLabelBMFont *label1 = CCLabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt");
addChild(label1);
label1->setPosition(ccp(s.width/2, s.height/4*3-20));
CCLabelBMFont *label2 = CCLabelBMFont::create(chinese, "fonts/arial-unicode-26.fnt");
addChild(label2);
label2->setPosition(ccp(s.width/2, s.height/4*2));
CCLabelBMFont *label3 = CCLabelBMFont::create(japanese, "fonts/arial-unicode-26.fnt");
addChild(label3);
label3->setPosition(ccp(s.width/2, s.height/4*1));
bRet = true;
} while (0);
return bRet;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
// "close" menu item clicked
CCDirector::sharedDirector()->end();
}
没有合适的资源?快使用搜索试试~ 我知道了~
cocos2dx在win32显示中文
共57个文件
tlog:18个
png:7个
h:5个
5星 · 超过95%的资源 需积分: 10 558 下载量 132 浏览量
2012-10-28
02:22:32
上传
评论 5
收藏 8.96MB RAR 举报
温馨提示
解决cocos2dx在win32显示中文乱码问题,两种处理变化方式,让其中文显示ok
资源推荐
资源详情
资源评论
收起资源包目录
显示中文test.rar (57个子文件)
HelloWorld
proj.win32
HelloWorld.win32.vcxproj 9KB
resource.h 500B
HelloWorld.rc 2KB
Tools.h 227B
Tools.cpp 925B
res
HelloWorld.ico 47KB
main.cpp 1KB
HelloWorld.win32.vcxproj.user 763B
HelloWorld.win32.vcxproj.filters 2KB
Debug.win32
link.7832-cvtres.write.1.tlog 2B
cl.command.1.tlog 6KB
link.7832.read.1.tlog 2B
Tools.obj 124KB
rc.command.1.tlog 2KB
CL.read.1.tlog 213KB
vc100.idb 1.42MB
mt.read.1.tlog 570B
HelloWorld.win32.exe.intermediate.manifest 381B
link-cvtres.read.1.tlog 2B
link.read.1.tlog 6KB
rc.read.1.tlog 3KB
HelloWorld.win32.lastbuildstate 94B
link.write.1.tlog 2KB
HelloWorld.res 47KB
CL.write.1.tlog 3KB
link.7832-cvtres.read.1.tlog 2B
link.7832.write.1.tlog 2B
vc100.pdb 668KB
HelloWorld.win32.log 3KB
HelloWorld.win32.Build.CppClean.log 920B
HelloWorld.win32.exe.embed.manifest 406B
main.obj 80KB
link.command.1.tlog 3KB
mt.write.1.tlog 570B
HelloWorld.win32_manifest.rc 234B
HelloWorldScene.obj 168KB
HelloWorld.win32.exe.embed.manifest.res 472B
mt.command.1.tlog 570B
rc.write.1.tlog 994B
AppDelegate.obj 101KB
link-cvtres.write.1.tlog 2B
main.h 270B
Classes
AppDelegate.cpp 1KB
HelloWorldScene.h 637B
HelloWorldScene.cpp 4KB
AppDelegate.h 960B
Resources
HelloWorld.png 142KB
fonts
arial-unicode-26.png 174KB
arial-unicode-26.fnt 20KB
strings.xml 346B
CloseNormal.png 6KB
fps_images-ipadhd.png 23KB
fps_images-hd.png 23KB
fps_images.png 7KB
CloseSelected.png 5KB
HelloWorld.sdf 39.14MB
HelloWorld.sln 920B
共 57 条
- 1
Potter
- 粉丝: 709
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页