iphone - cocos2d screen orientation problems -


i using standard rotation code present in cocos2d 0.99-rc0 support portrait + 2 landscape modes. showing menu in portrait mode, , screen rotates landscape actual game. problem when go portrait, whole mainmenu scene off half screen, had moved anchor point or something.

any ideas please?

a possible simple solution apply orientation @ start of scene after wards re-apply positions of menu items aligned.

i following change screen orientation:

firstly, first line goes inside init method set timer start after quick 0.5 seconds. putting in timer means in game scene transition (fade) works smoothly, screen doesn't rotate/snap round then, won't need use this.

[self schedule:@selector(rotate:) interval:0.5];  -(void)rotate:(cctime) dt{     [[ccdirector shareddirector] setdeviceorientation:ccdeviceorientationlandscapeleft];     [self unschedule:@selector(rotate:)]; } 

the key line below, don't need timer:

[[ccdirector shareddirector] setdeviceorientation:ccdeviceorientationlandscapeleft]; 

of course can alter bit different orientations:

ccdeviceorientationlandscapeleft ccdeviceorientationlandscaperight ccdeviceorientationportrait ccdeviceorientationportraitupsidedown 

good luck.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -