Note:
1. 打开GameConfig.h文件, 定义Autorotation类型, kGameAutorotationUIViewController by default:
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController
/*
#define kGameAutorotationNone 0
#define kGameAutorotationCCDirector 1
#define kGameAutorotationUIViewController 2
/*
2.在RootViewController里,找到如下方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
根据Config里定义的类型,选择屏幕适应性: 源代码里都有很好的范例:
#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight )
return YES;
// Unsupported orientations:
// UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown
return NO;
例如只想显示Portrait:
if( interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
Cocos2d – 禁止屏幕自动旋转
最新推荐文章于 2023-02-21 14:03:29 发布