Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #import "cocos2d.h"
00014
00015 #import "RootViewController.h"
00016 #import "GameConfig.h"
00017
00018 @implementation RootViewController
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #if GAME_AUTOROTATION==kGameAutorotationNone
00056
00057
00058
00059
00060
00061 return ( interfaceOrientation == UIInterfaceOrientationPortrait );
00062
00063 #elif GAME_AUTOROTATION==kGameAutorotationCCDirector
00064
00065
00066
00067
00068
00069 if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
00070 [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight];
00071 } else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
00072 [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft];
00073 }
00074
00075
00076
00077 return ( interfaceOrientation == UIInterfaceOrientationPortrait );
00078
00079 #elif GAME_AUTOROTATION == kGameAutorotationUIViewController
00080
00081
00082
00083
00084
00085
00086
00087 return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
00088
00089 #else
00090 #error Unknown value in GAME_AUTOROTATION
00091
00092 #endif // GAME_AUTOROTATION
00093
00094
00095
00096 return NO;
00097 }
00098
00099
00100
00101
00102 #if GAME_AUTOROTATION == kGameAutorotationUIViewController
00103 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
00104 {
00105
00106
00107
00109 CGRect screenRect = [[UIScreen mainScreen] bounds];
00110 CGRect rect = CGRectZero;
00111
00112
00113 if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
00114 rect = screenRect;
00115
00116 else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
00117 rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width );
00118
00119 CCDirector *director = [CCDirector sharedDirector];
00120 EAGLView *glView = [director openGLView];
00121 float contentScaleFactor = [director contentScaleFactor];
00122
00123 if( contentScaleFactor != 1 ) {
00124 rect.size.width *= contentScaleFactor;
00125 rect.size.height *= contentScaleFactor;
00126 }
00127 glView.frame = rect;
00128 }
00129 #endif // GAME_AUTOROTATION == kGameAutorotationUIViewController
00130
00131
00132 - (void)didReceiveMemoryWarning {
00133
00134 [super didReceiveMemoryWarning];
00135
00136
00137 }
00138
00139 - (void)viewDidUnload {
00140 [super viewDidUnload];
00141
00142
00143 }
00144
00145
00146 - (void)dealloc {
00147 [super dealloc];
00148 }
00149
00150
00151 @end