Skip to content

Commit 60df1c9

Browse files
committed
Move scene creation in directorDidReshapeProjection into ios setup methods. Fix for iOS 7.
1 parent b27e323 commit 60df1c9

File tree

4 files changed

+19
-47
lines changed

4 files changed

+19
-47
lines changed

cocos2d/CCDirector.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@
8787
/** Returns a Boolean value indicating whether the CCDirector supports the specified orientation. Default value is YES (supports all possible orientations) */
8888
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
8989

90-
/** Called when projection is resized (due to layoutSubviews on the view). This is important to respond to in order to setup your scene with the proper dimensions (which only exist after the first call to layoutSubviews) so that you can set your scene as early as possible to avoid startup flicker
91-
- */
92-
-(void) directorDidReshapeProjection:(CCDirector*)director;
93-
9490
#endif // __CC_PLATFORM_IOS
9591

9692
@end

cocos2d/Platforms/CCAppController.m

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,40 +115,41 @@ - (void)setupIOS
115115
{
116116
_cocosConfig = [self iosConfig];
117117

118-
[self applyConfigurationToCocos:_cocosConfig];
119-
[self setFirstScene];
120-
}
121-
122-
- (void)applyConfigurationToCocos:(NSDictionary*)config
123-
{
124118
CCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
125119
[appDelegate constructWindow];
126120

127-
_glView = [appDelegate constructView:config withBounds:appDelegate.window.bounds];
128-
121+
_glView = [appDelegate constructView:_cocosConfig withBounds:appDelegate.window.bounds];
122+
129123
CCDirector *director = _glView.director;
130124
NSAssert(director, @"CCView failed to construct a director.");
131-
[self configureDirector:director withConfig:config withView:_glView];
132-
125+
[self configureDirector:director withConfig:_cocosConfig withView:_glView];
126+
133127
[CCDirector pushCurrentDirector:director];
134-
135-
if([config[CCSetupScreenMode] isEqual:CCScreenModeFixed]){
136-
[self setupFixedScreenMode:config director:(CCDirectorIOS *) director];
128+
129+
if([_cocosConfig[CCSetupScreenMode] isEqual:CCScreenModeFixed]){
130+
[self setupFixedScreenMode:_cocosConfig director:(CCDirectorIOS *) director];
137131
} else {
138-
[self setupFlexibleScreenMode:config director:director];
132+
[self setupFlexibleScreenMode:_cocosConfig director:director];
139133
}
140-
134+
141135
// Initialise OpenAL
142136
[OALSimpleAudio sharedInstance];
143137

144-
[appDelegate constructNavController:config];
145-
138+
[appDelegate constructNavController:_cocosConfig];
146139
[[CCPackageManager sharedManager] loadPackages];
147-
140+
148141
[appDelegate.window makeKeyAndVisible];
149142
[appDelegate forceOrientation];
150143

151144
[CCDirector popCurrentDirector];
145+
146+
[self runStartSceneiOS];
147+
}
148+
149+
- (void)runStartSceneiOS
150+
{
151+
CCDirector *director = _glView.director;
152+
[director presentScene:[self startScene]];
152153
}
153154

154155
- (void)configureDirector:(CCDirector *)director withConfig:(NSDictionary *)config withView:(CC_VIEW <CCView> *)ccview
@@ -209,12 +210,6 @@ - (void)setupFixedScreenMode:(NSDictionary *)config director:(CCDirectorIOS *)di
209210
[director setProjection:CCDirectorProjectionCustom];
210211
}
211212

212-
- (void)setFirstScene
213-
{
214-
CCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
215-
appDelegate.startScene = [self startScene];
216-
}
217-
218213
#endif
219214

220215
#pragma mark Android setup

cocos2d/Platforms/iOS/CCAppDelegate.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,6 @@ -(GLKMatrix4)updateProjection
102102

103103
return GLKMatrix4MakeOrtho(offset.x, sizePoint.width + offset.x, offset.y, sizePoint.height + offset.y, -1024, 1024);
104104
}
105-
106-
-(void) directorDidReshapeProjection:(CCDirector*)director
107-
{
108-
if(director.runningScene == nil) {
109-
CCScene * scene = [_appDelegate startScene];
110-
111-
// Add the first scene to the stack. The director will draw it immediately into the framebuffer. (Animation is started automatically when the view is displayed.)
112-
// and add the scene to the stack. The director will run it when it automatically when the view is displayed.
113-
[director presentScene: scene];
114-
}
115-
}
116105

117106
@end
118107

cocos2d/Platforms/iOS/CCDirectorIOS.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ -(void) end
149149

150150
#pragma mark Director - UIViewController delegate
151151

152-
-(void) reshapeProjection:(CGSize)newViewSize
153-
{
154-
[super reshapeProjection:newViewSize];
155-
156-
if( [_delegate respondsToSelector:@selector(directorDidReshapeProjection:)] )
157-
[_delegate directorDidReshapeProjection:self];
158-
}
159-
160152
-(void) setView:(CC_VIEW<CCView> *)view
161153
{
162154
[super setView:view];

0 commit comments

Comments
 (0)