cocos2d-x如何修改设备方向 各位高手,请问一下cocos2d-x这个引擎如何改变设备的方向呢?cocos2d可以调用 setDeviceOrientation函数修改,但是cocos2d-x引擎并没有这个方法,请教一下如何解决这个问题,多谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 cocos2dx 并没有setDeviceOrientation, 因为这个和具体平台有关系. 你可以通过修改PROJECT_ROOT/ios/RootViewController.mm中的 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 实现ios版本的. //iOS://RootViewController.mm里修改- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsPortrait( interfaceOrientation );//UIInterfaceOrientationIsPortrait竖屏//UIInterfaceOrientationIsLandscape横屏}// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead- (NSUInteger) supportedInterfaceOrientations{#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskPortrait;#endif}- (BOOL) shouldAutorotate { return NO;}//Android//在onCreate里添加//锁定竖屏this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 这个和平台相关,要修复对应的API如IOS1、新建一个cocos2d-x项目<IOS>;2、AppDelegate.cpp 中大约 84行,注释pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeRight); 3、重载RootViewController.mm 中的 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return UIInterfaceOrientationIsLandscape( interfaceOrientation );}4、不需要在Info.plist中添加 Supported interface orientations。 跪求IOS方面Iphone、Ipad等方面视频 如何清空uitableview中现有的内容? 如何设置父类的属性的初始值? IOS开发应用是否可以后台截图? 关于Xcode下得vvdocumenter插件要怎么删除 怎么把进入相册选取照片之后进入的裁剪页里面的裁剪框控制大小? PP助手导入的视频无法读取 关于MKMapView中setRegion对于delegate调用的影响 iOS开发 聊天不显示怎么解决呀 有没有大神写出了ios的模拟器,想在电脑上玩ios区游戏的 IOS图片播放问题 各位开发ios的你们都用的什么笔记本啊?
//RootViewController.mm里修改
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
//UIInterfaceOrientationIsPortrait竖屏
//UIInterfaceOrientationIsLandscape横屏
}// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskPortrait;
#endif
}- (BOOL) shouldAutorotate {
return NO;
}
//Android
//在onCreate里添加
//锁定竖屏
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
如IOS1、新建一个cocos2d-x项目<IOS>;2、AppDelegate.cpp 中大约 84行,注释pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeRight);
3、重载RootViewController.mm 中的 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return UIInterfaceOrientationIsLandscape( interfaceOrientation );}4、不需要在Info.plist中添加 Supported interface orientations。