COCOS2D-X临时设置竖屏,过一阵子再设置回横屏

mainActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
竖屏是JAVA代码

另外再修改COCOS2D-X坐标系统(C++代码)(20140602这是ANDROID和IOS都需要的):

CCEGLView *view = CCEGLView::sharedOpenGLView();
	CCSize czFrame = view->getFrameSize();
	view->setFrameSize(czFrame.height,czFrame.width);
	view->setDesignResolutionSize(320,480,kResolutionExactFit);


设置回来代码和上面的相反


设置android-14转屏就崩溃,设置android-11就不崩溃,不知道为什么。(20140511)



20140602总结IOS下要做的事:

设备旋转不要打钩:



 在RootViewController里,代码控制是否旋转,你要修改这些代码来适应你自己的程序:

- (BOOL) shouldAutorotate {
    bool bIsPortraitCur = ( self.interfaceOrientation == UIInterfaceOrientationPortrait );
    if( bIsPortraitCur != s_needOrientation )
        return YES;
    else
       return NO;
    return YES;
//    return NO;
}


// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskAll;
#endif
}

旋转的IOS代码:

extern bool s_needOrientation;
bool SetScrnOrentation( bool bIsPotrit ){
    if(s_needOrientation == bIsPotrit )
        return false;
    
    s_needOrientation = bIsPotrit ;
	[[UIDevice currentDevice] performSelector:@selector(setOrientation:)
        withObject:
     bIsPotrit ? (id)UIDeviceOrientationPortrait : (id)UIDeviceOrientationLandscapeRight];
    //[[UIApplication sharedApplication] setStatusBarOrientation:bIsPotrit?UIInterfaceOrientationPortrait:UIInterfaceOrientationLandscapeRight];

    return true;
}





评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值