Cocos2d-x 設置豎屏的方法 2.0以上版本


在網上搜了千百遍終於終於找到對的方法了。。

在網上搜的大部分結果是把(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation();函數中的語句改成如注釋掉的:

 

 

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    returnUIInterfaceOrientationIsLandscape( interfaceOrientation );

//    return (UIInterfaceOrientationIsPortrait( interfaceOrientation ));

}

 

可是在本人機子上做實驗就是不成功。。。我的cocos2d的版本是2.1beta3-x-2.1.1

 

最終正確的方法如下:不是修改上面的函數而是把(NSUInteger) supportedInterfaceOrientations();函數中的語句改成注釋掉的

 

- (NSUInteger) supportedInterfaceOrientations{

#ifdef __IPHONE_6_0

 

    returnUIInterfaceOrientationMaskLandscape;

//     return UIInterfaceOrientationMaskPortrait;

 

#endif

}

這樣實驗就成功了。。。

兩函數所在目錄:Cocos2d-x項目目錄iOS目錄中的RootViewController.mm文件中。。。

 

 

如果你試驗還是不成功試着把RootViewController.mm文件中的如下3個函數全部改成注釋掉的部分:

 

函數一:

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return UIInterfaceOrientationIsLandscape( interfaceOrientation );

//    return (UIInterfaceOrientationIsPortrait( interfaceOrientation ));

}

 

函數二:

 

- (NSUInteger) supportedInterfaceOrientations{

#ifdef __IPHONE_6_0

 

    return UIInterfaceOrientationMaskLandscape;

//     return UIInterfaceOrientationMaskPortrait;

 

//    直式顯示: protrait

//    橫式顯示: landscape

 

 

#endif

}


函數三:

 

- (BOOL) shouldAutorotate {

    returnYES;

 

//    return NO;

 

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM