cocos2d v3 re-orient screen during App use

后端 未结 1 1598
面向向阳花
面向向阳花 2021-01-26 01:06

So in cocos2d (I believe I was on v2.1) I did this to lock and set the orientations:

        AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplica         


        
相关标签:
1条回答
  • 2021-01-26 02:01

    After a couple days fooling around I figured out a solution:

    in AppDelegate I needed this function:

    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        if (!self.lockedToOrientation) {
            if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ){
                return UIInterfaceOrientationMaskPortrait;
            }
    
            return UIInterfaceOrientationMaskPortrait;
        }
        else {
            return self.lockedToOrientation;
        }
    }
    

    Where

    @property UIInterfaceOrientationMask lockedToOrientation;
    

    Hope this helps someone!

    Cheers.

    0 讨论(0)
提交回复
热议问题