cocos2d-x遊戲開發中的一些個人總結 。

來源:互聯網
上載者:User

很重要的結論:
cocos2d-x  

你可以在進入CCSCene 之前進行建立Sprite 
但是 【刪除sprite 對象】 必須在退出CCScene 之前刪除 
否則刪除 會導致CCTexture2D::~CCTexture2D() {
glDeleteTextures(1, &m_uName);   // CRASH !!!    
}

scheduleUpdate 為對 target 的 retainCount +1 
CCCallfun 也會對target的 retainCount +1 

CCSpriteBatchNode 指定texture 後,下面的Sprite 對象 的texture 必須為batchnode所指的texture.

bug on cocos2d-x 
ccsequnce::create(ccaction ,....);  never use this function.

schedule_selector  的select函數 的參數 一定要匹配

C++: 

1.模板的分離編譯問題~
2.父類的解構函式要加virtual .以防無法調用到子類的解構函式 。
3.取消提示 >          g:\ip\dev\iphone dev\cocos2d\planefps\classes\entity\enemy\vehiclegroup.h(55): 編譯類 模板 成員函數“VehicleGroup<T> *VehicleGroup<T>::buildGroup(Path *,Vector2D,int,float)”時
1>          with
1>          [
1>              T=TTMyEnemy
1>          ]
1>          g:\ip\dev\iphone dev\cocos2d\planefps\classes\entity\enemy\enemygroupbuilder.h(15): 參見對正在編譯的類 模板 執行個體化“VehicleGroup<T>”的引用
1>          with
1>          [
1>              T=TTMyEnemy
1>          ]
將調用模板方法的地方放入cpp檔案 裡面
 使用 C++拷貝函數 原型模式

/* C++拷貝函數 不會自動 調用基類的拷貝函數 ,而且基類的拷貝函數要重寫才能調用。 */

調用頻繁的函數 ,盡量寫成 inline 函數 。避免了頻繁的跳轉,出入踐

static 在ios 上自動析構????

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.