iOS匯入cocos2d遊戲

來源:互聯網
上載者:User

標籤:

一、xcode中在自己項目中引入cocos2dx,需要匯入cocos2d_libs靜態庫。首先需要到官網下載cocos2d引擎,cocos2d引擎下載連結點擊進入官網

二、將cocos2d引擎拷貝到工程目錄,在工程中add Files..添加到工程中。

三、添加依賴庫

四、對工程進行配置

1、Build Settings中配置
設定Valid Architectures

2、Build Options ->Enable Bitcode 設定為NO

3、設定Other Linker Flages 如下

4、project中設定Header Search Paths,相對路徑,cocos2d檔案夾放在ImportCocos2D2.xcodeproj的同級目錄,所以是這個路徑。$(SRCROOT)是.xcodeproj所在位置

5、設定Other C flages
-DNS_BLOCK_ASSERTIONS=1
6、

7、Apple LLVC 7.0 – PreProcessing
debug :
USE_FILE32API
CC_TARGET_OS_IPHONE
COCOS2D_DEBUG=1
CC_ENABLE_CHIPMUNK_INTEGRATION=1

Release
USE_FILE32API
CC_TARGET_OS_IPHONE
CC_ENABLE_CHIPMUNK_INTEGRATION=1

8、Apple LLVM 7.0 Warnings –All languages

9、設定pch路徑

五、載入cocos2d遊戲檔案,需要修改delegate名稱,修改main中代理名稱

//main函數內容#import <UIKit/UIKit.h>#import "AppController.h"int main(int argc, char * argv[]) {    @autoreleasepool {        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppController class]));    }}
//pch內容#ifdef __OBJC__    #import <Foundation/Foundation.h>    #import <UIKit/UIKit.h>#endif#ifdef __cplusplus    #include "cocos2d.h"#endif

運行效果:

iOS匯入cocos2d遊戲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.