cocos2dx筆記005 乙個字串管理配置類

2021-09-08 04:47:14 字數 1370 閱讀 5840

在用vs開發cocos2dx過程中。要顯示的中文,要求是utf-8格式的才幹正常顯示出來。但vs通常是ansi格式儲存,這樣,在**中寫入的中文字串,執行後。顯示的就是亂碼。

為了正確顯示中文。或支援多語言,我這裡定義乙個簡單的字串管理類,來滿足上述要求。

以下是**://

字串資源管理器

#ifndef _x_string_manager_h_

#define _x_string_manager_h_

#include 

#include 

#include 

#include 

#include 

namespace zdh

~xstringmgr()

xint load(

const xansistring & paramfilename, 

bool paramclear = 

true)

}

return err_ok;

}

//取指定字串物件。假設不存在,返回null

const xansistring * getstringex(

const xansistring & paramsection, 

const xansistring & paramkey)

//取指定的字串,假設不存在,則返回空串

const

char * getstring(

const xansistring & paramsection, 

const xansistring & paramkey)

const tstringsection & getmap() 

const

private:

tstringsection m_map;

};

}

#define string_mgr zdh::xsingletonsample::getinstance()

#define string_section_main "main"

#define string_play (string_mgr->getstring(string_section_main, "play"))

#define string_font (string_mgr->getstring(string_section_main, "font"))

#endif

使用樣例

xansistring strstringmgrfilename("string_zh.ini");

if (zdh::isnotok(string_mgr->load(strstringmgrfilename)))

else

cocos2d x 學習筆記 一

最近有點閒,突然想嘗試搞搞手機遊戲方面的開發,於是下了個cocos2d x 2.2.6和 cocos2d x權威指南 先看書,翻了下目錄尼瑪16章。厄,對於這種工具框架類的學習,貌似我從來沒有按部就班慢慢學的習慣 照例,花了2,3小時看下大概概念,記錄下 1,背景知識,過 2,環境搭建,cocos2...

cocos2d x 第乙個專案

還記得這個介面麼,5種可選擇的模板。我們選擇cocos2dx標準模板即可。如下圖輸入product name和company identifier 我在重要的地方都加了注釋 在看 之前,我稍微介紹幾個類的概念。cocos2dx hello world created by wenbin.cai on...

第乙個cocos2d x程式

目的 在介面上顯示3個精靈。做法 建立乙個cocos2dx專案之後重寫 init 方法。段如下 on init you need to initialize your instance bool helloworld init ccsprite bg ccsprite create icon.png...