Cocos2dx: How to set up portrait screen for ios and Android, cocos2dxandroid

Source: Internet
Author: User

Cocos2dx: How to set up portrait screen for ios and Android, cocos2dxandroid
Cocos2d-x compiled to ios, the default is landscape, if you want to change to http: // portrait screen, different ios versions, the method will be different

On ios7, we may have configured a portrait screen, but it may change to ios6. BelowIn vainShare with you my practices

Reprinted please indicate the address http://blog.csdn.net/u010229677

1. General

In the RootViewController. mm file

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {    return UIInterfaceOrientationIsPortrait( interfaceOrientation );}// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead- (NSUInteger) supportedInterfaceOrientations{#ifdef __IPHONE_6_0    return UIInterfaceOrientationMaskPortrait;#endif}- (BOOL) shouldAutorotate {    return NO;}


---- You can also do this -----

If ([[UIDevice currentDevice] respondsToSelector: @ selector (setOrientation :)]) {[[UIDevice currentDevice] performSelector: @ selector (setOrientation :) withObject :( id) UIInterfaceOrientationPortrait];} // But-(BOOL) shouldAutorotate {return NO;} // no must be returned


In addition, You must select the project's General property Deployment Info Portrait.

2. You can set the view to be consistent with the battery entry direction.

In AooController. mm

<span style="font-size:18px;">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions </span>

Add a sentence to this function.

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated: NO];


To change the android project to a horizontal screen, modify the xml file:

Set in AndroidManifest. xml

Android: screenOrientation = "portrait"



Ios and android are both developed in the native language. Which one is faster than cocos2dx? Because cocos2dx has various problems.

Cocos2dx is used for game development. If it is used, it is certainly not possible to use the game engine. The game uses cocos2dx in a complex way, and the engine is not needed if it is not complex.

When the layout of the horizontal and vertical screens of android is different, do I need onCreate () to reload them?

Reload by default... you need to change

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.