デバイスを横向きまたは横向きにすることができるゲームを作成しています。プレーヤーは、一時停止しているときに向きを変更できます。その場合、方向に基づいてゲームが加速度計を解釈する方法を変更する必要があります。
iOS 5では、willRotateToInterfaceOrientationを使用して変更をキャッチし、変数を変更しましたが、iOS6では非推奨になりました。私の既存のコードは次のようになります。
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
rect = screenRect;
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width );
GameEngine *engine = [GameEngine sharedEngine];
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
engine.orientation = -1;
} else {
engine.orientation = 1;
}
}
置換はUIViewControllerクラスのviewWillLayoutSubviewsメソッドであることを理解しています。私はこのゲームをcocos2d2.1で構築していますが、デモプロジェクトにUIViewControllerクラスがないようです。そのため、このゲームを組み込む方法と、これを機能させるためのコードの外観がわかりません。