投稿

2013の投稿を表示しています

【Xcode】 ファイル毎にARCの有効・無効を設定する

### XcodeでARC (Automatic Reference Counting)をプロジェクト単位で設定する。 - “TARGET” を選択し、”Build Phases” の “Compile Sources” に以下を付与させる - ARC を有効化したい場合 - `-fobjc-arc` - ARC を無効化したい場合 - `-fno-objc-arc`

Box2Dで作ったオブジェクトをiOSの加速度に対応させるの巻!

```obj-c #import #import @interface HomeViewController (){ b2World *world; NSTimer *timer; } @end @implementation ViewController - (void)loadView { [super loadView]; acc = [UIAccelerometer sharedAccelerometer]; acc.updateInterval = 1.0f / 10.0f; acc.delegate = self; // 通知を開始させたい時に実行する } - (void)createPhysicsWorld { CGSize screenSize = self.view.bounds.size; b2Vec2 gravity; gravity.Set(0.0f, -9.81f); world = new b2World(gravity); world->SetContinuousPhysics(true); b2BodyDef groundBodyDef; groundBodyDef.position.Set(0, 0); b2Body* groundBody = world->CreateBody(&groundBodyDef); b2EdgeShape groundBox; groundBox.Set(b2Vec2(0, 0), b2Vec2(screenSize.width/PTMRatio, 0)); groundBody->CreateFixture(&groundBox, 0); groundBox.Set(b2Vec2(0,screenSize.height/PTMRatio), b2Vec2(0,0)); groundBody->CreateFixture(&groundBox, 0); groundBox.Set(b2Vec2(screenSize.wi