基本コードを少し変更してデフォルトの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
HTMLフォーマットを使わずにコードを再投稿してください。それは読めない瞬間です。 – LearnCocos2D