前提
- 物理エンジンを使わない
- Cocos2d-x3.0
- iOS(Androidはこれ見るといい http://qiita.com/akerusoft/items/3d5068e8bfe926b03969
作業
- ccConfig.h の
CC_USE_PHYSICS
を0にする - アプリ側のprojectからbox2d/chipmunkを除く
- cocos2dx_libsからchipmunkを除く
ccConfig.h のCC_USE_PHYSICS
を0にする
--- a/App/cocos2d/cocos/2d/ccConfig.h +++ b/App/cocos2d/cocos/2d/ccConfig.h @@ -269,7 +269,7 @@ To enable set it to a value different than 0. Disabled by default. /** Use physics integration API */ #ifndef CC_USE_PHYSICS -#define CC_USE_PHYSICS 1 +#define CC_USE_PHYSICS 0 #endif
cocos2d-xのPhysics系のクラスは#if CC_USE_PHYSICS
で囲まれてるので、これだけでもビルドが少しだけ早くなる。
また、CCNodeの中で↓こんなコードがあるので、CC_USE_PHYSICS=0にしておけば、if文1個分処理速度向上すると思う。
#if CC_USE_PHYSICS if (_physicsBody) { _physicsBody->setRotation(_rotationZ_X); } #endif
アプリ側のprojectからbox2d/chipmunkを除く
- projectの
Build Phases
に移動 Target Dependencies
からchipmunk iOS
とbox2d iOS
を消すLink Binary With Libraries
からlibbox2d iOS.a
とlibchipmunk iOS.a
を消す
Macについても同じ作業する。
cocos2dx_libsからbox2d/chipmunkを除く
- cocos2d_libsの
Build Phases
に移動 Target Dependencies
からchipmunk iOS
を消すLink Binary With Libraries
からlibchipmunk iOS.a
を消す
以上。
ビルド時間の変化
time xcodebuild -project '/path/to/AppName.xcodeproj' -scheme 'AppName iOS' -sdk iphoneos -configuration Release CODE_SIGN_IDENTITY='iPhone Distribution' build
時間の計測は、cleanしてから上記コマンドを実行して調べた。
- 1181.91s user 100.55s system 647% cpu 3:18.04 total(変更前
- 1147.27s user 99.05s system 638% cpu 3:15.09 total(CC_USE_PHYSICS=0
- 1116.01s user 95.00s system 637% cpu 3:10.08 total(projectからbox2d/chipmunk除去
- 1101.31s user 92.41s system 643% cpu 3:05.42 total(cocos2dx_libsからbox2d/chipmunk除去
というような感じで、timeの出力の見方分からないけど早くなってるっぽい。