2012-01-14 6 views
2

基本コードを少し変更してデフォルトのcocos2dテンプレートを使用しています。
私のゲームは左または右にのみ再生されます。肖像はありません。

ゲームが開始されると、ゲームが開始された後、逆さまにフリップされた後、再び右にフリップされます。
私はこの問題に関するいくつかの記事を見て、デバイスを移動させずにインターフェイスを前後にフリップさせていることに私の指を置くように見えません。
ありがとうございました!

私は、次の関連コードを持っている:

RootViewController.m:
起動時にCocos2dゲームの向きが左→右→左に切り替わります

#if GAME_AUTOROTATION == kGameAutorotationUIViewController 

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    CGRect screenRect = [[UIScreen mainScreen] bounds]; 
    CGRect rect = CGRectZero; 

    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)  
     rect = screenRect; 

    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
     rect.size = CGSizeMake(screenRect.size.height, screenRect.size.width); 

    CCDirector *director = [CCDirector sharedDirector]; 
    EAGLView *glView = [director openGLView]; 
    float contentScaleFactor = [director contentScaleFactor]; 

    if(contentScaleFactor != 1) { 
     rect.size.width *= contentScaleFactor; 
     rect.size.height *= contentScaleFactor; 
    } 
    glView.frame = rect; 
} 
#endif 

AppDelegate:

#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
    [director setDeviceOrientation:kCCDeviceOrientationPortrait]; 
#else 
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight]; 
#endif 

GameConfig.h:

#define kGameAutorotationNone 0 
#define kGameAutorotationCCDirector 1 
#define kGameAutorotationUIViewController 2 

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR 
#define GAME_AUTOROTATION kGameAutorotationUIViewController 

#elif __arm__ 
#define GAME_AUTOROTATION kGameAutorotationNone 
+0

HTMLフォーマットを使わずにコードを再投稿してください。それは読めない瞬間です。 – LearnCocos2D

答えて

3

私は同じ問題を抱えていました今日、それはordに落ちたようです私のアプリケーションのplistでサポートされている方向性の。アプリはLandscape Leftで起動し、右にフリップしてから、本当にすばやく左に移動します。

「概要」タブ(サポートされている向き、アプリケーションアイコン、起動画像など)でプロジェクトプロパティに入り、サポートされているすべての向きの選択を解除しました。

次に、(Landscape Right、Landscape Left)順番にもう一度チェックを入れ、「Info」タブで、この順序で配列の「サポートされているインターフェイスの向き」セクションで確認しました。

項目0 - 風景(右ホームボタン) 項目1 - 風景(左ホームボタン)

これが役に立てば幸い、以来、問題を抱えていたわけではありません。

+0

ありがとうございました!あなたはこの愚かなことでどれくらいの時間を失ったのか分かりません! – Lio

関連する問題