When I call CGSize winSize = [[CCDirector sharedDirector]winSize];
in cocos2d from the init method of the root view controller and nslog "winSize" right after it reports that the screen is in portrait when in fact its in landscape. This error doesn't occur when you call it from -(void)onEnter or from a view that was loaded from the root view. I see that a few other people are having this problem after googling the problem but no one really seams to know how to fix it or the answer doesn't apply to me.
Asked
Active
Viewed 3,585 times
7
1 Answers
12
Yes, This is one of the serious problem in cocos2D 2.0. When I try in init method of first scene.
Instead of init try onEnter.
-(void)onEnter
{
[super onEnter];
CGSize winSize = [[CCDirector sharedDirector]winSize];
//Place all your init functions here.
}
Note: In iphone5, missing Default-568h@2x.png also result wrong size!!! Cocos2d 3.0:
CGSize s = [[CCDirector sharedDirector] viewSize];

Guru
- 21,652
- 10
- 63
- 102
-
yeah... but how to get size inside the first scene's init? – Andrew May 11 '13 at 17:21
-
1update your cocos2d to new version. In new version works great. – Guru May 12 '13 at 04:36