2013年11月12日 星期二

ios7 只能用cocos2D v2.x版了

查詢了官網最新的v1.1RC0版 說明相關資料

* Base SDK 4.1 or newer should be used.
  • Don't report bugs if you are using a previous version.
  • Don't you have Base SDK 4.1 ? Install Xcode 3.2.6 or newer.
  • How to set Base SDK to 4.1: Xcode → Project → Edit project Settings → Build → Base SDK
Only Xcode 4 can be used with cocos2d, Xcode 3 isn't supported anymore.
With Xcode versions below 4.2.1 the compiler will generate warnings about '#pragma clang' statements. These can be safely commented out.
CocosLive is not supported anymore and has been taken out of the templates.
This version still supports armv6 (iPhone 3G, iPod touch 2G and lower), to compile for armv6 use Xcode 4.4.1 or lower.
RC0 has been tested intensively and will also become the stable release of 1.1., if no show stopping bugs will be found.

iPhone5 + iOS6 support


因此可以說沒救了,只能使用v2.1版了,希望程式碼不需要改動太多才好。


官方參考網址
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:migrate_to_v2.0


改版過程失敗

1. CCNode.h的position_ 變數,改版後變成 _position , tag_及 contentSize_也是一樣

2. Box2D 中的b2DebugDraw 變成 b2Draw

3....


最重要的是如果外部代碼直接使用OPENGLES1,那就真的難救了。
只能就部分了解的想辦法解決了。

大改寫可能會比較快一些,並且可就了解的部分再最佳化了。 


Xcode的array語法使用誤例

Xcode 的C++語法比較嚴謹

b2Vec2 vertices[vertexCount]; ==> 不可以這樣用,要改成下面的方法
錯誤告示  variable length array of non-POD element type 'b2Vec2'

   
b2Vec2 *vertices = new b2Vec2[vertexCount]; // 修改後可用,xcode比較嚴謹


使用後要手動使用delete來釋放記憶體。
delete [] vertices; 
 
 
另外一種用法,改成vector
a)
std::vector<b2Vec2> vertices(count);
vertices[0].set(2, 3);
vertices[1].set(3, 4);
...

b)
std::vector<b2Vec2> vertices;
vertices.push_back(b2Vec2(2, 3));
vertices.push_back(b2Vec2(3, 4)); 

Box2D在Xcode上的使用設定

基本環境,已經加入cocos2D,然後需要加入Box2D時,其設定如下。

1.將Box2D的source Code加入到Project下,原始碼放在cocos2D/external下,先放在libs次目錄下。


2. 設定Build搜尋目錄

3. 所有使用到Box2D的.m檔,其副檔名改成.mm,這樣才能吃進c++所寫的Box2D