Cocos2d x 新增字型庫

2021-06-20 17:18:07 字數 1141 閱讀 8623

步驟一:找乙個ttf字型庫

步驟二:找到這個ttf字型庫的真實名稱

開啟你的應用 「字型冊」(mac os系統下),如下圖操作):

找到了字型庫真實名稱,那麼修改將其真名作為為此新的字型庫名稱即可。

然後將其加入你的專案中即可使用

步驟三:

開啟xcode專案資源下的info.plist檔案:

(將新加的字型庫真名加入此條目列表下即可)

剩下,我們書寫測試**:

1

2

3

4

5

6

7

8

9

10

//使用系統自帶字型庫

cclabelttf* plabel = cclabelttf::create("自帶字型庫","thonburi", 50);

ccsize size = ccdirector::shareddirector()->getwinsize();

plabel->setposition( ccp(size.width / 2, size.height*0.5 + 30) );

this->addchild(plabel, 1);

//使用新加的字型庫

cclabelttf* plabelhimi = cclabelttf::create("himi 新加字型庫","dfkantingliuw9.ttf", 50);

plabelhimi->setposition( ccp(size.width / 2, size.height*0.5 - 40) );

this->addchild(plabelhimi, 1);

run

cocos2dx 字型設定

設定字型 cclabelttf plabel1 cclabelttf create hello world thonburi 24 cclabelttf plabel1 cclabelttf create hello world stkaiti 24 plabel1 setposition ccp ...

cocos2dx新增虛擬彈幕

給單機遊戲新增準備好的彈幕。直接上 作為乙個記錄 在gamelayer.h中宣告控制項和方法 public virtual void update float dt 更新 void adddanmu float dt 新增彈幕 private node panel danmu 彈幕 float da...

cocos2d x 之 新增sns分享

步驟一 先寫activity內容 其實就是share函式。package org.jw.bj import org.cocos2dx.lib.cocos2dxactivity import android.content.intent import android.net.uri import an...