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
 //横式显示:UIInterfaceOrientationMaskLandscape  
 //直式显示:UIInterfaceOrientationMaskPortrait
    return UIInterfaceOrientationMaskLandscape;
//  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;
}

源地址:http://www.cnblogs.com/GameDeveloper/archive/2013/04/17/3026414.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值