Mac cocos2d-x 3.8 Setting horizontal screen/Vertical screen

Source: Internet
Author: User
Tags lua

Using the command, create a new Cocos2d-lua project named demo with the following command:

New Demo-p com.demo.org-l lua-d/users/user name/documents/cocos2d-x-3.8. 1/projects

After the creation is successful, then use Xcode to open: /projects/demo/frameworks/runtime-src/proj.ios_mac/demo.xcodeproj

Run the project and find the window that is horizontal, however, I want the window to be vertical, and its implementation steps are as follows:

(1) Open ios/rootviewcontroller.mm,:

Modify function One:

 //  Override to allow orientations other than The default portrait orientation.  // //Portrait portrait, Landscape landscape - (BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation { if  (simpleconfigparser::getinstance ()->islanscape ()) { return   Uiinterfaceorientationislandscape (interfaceorientation);  else  { return   uiinterfaceorientationisportrait (interfaceorientation); }}

Depending on the individual needs, it can be changed, such as:return uiinterfaceorientationisportrait (interfaceorientation);

Modify function Two:

 //  for IOS6, use Supportedinterfaceorientations & Shouldautorotate instead - (Nsuinteger) supportedinterfaceorientations{#ifdef __iphone_6_0  if  ( Simpleconfigparser::getinstance ()->islanscape ()) { //  landscape  return   Uiinterfaceorientationmasklandscape;  else  { //  portrait  return   uiinterfaceorientationmaskportrait;   #endif  }  

According to individual needs, it can be modified to, such as: return uiinterfaceorientationmaskportrait;

Modify function Three:

// whether screen rotation is supported - (BOOL) shouldautorotate    {if (Simpleconfigparser::getinstance ()  Islanscape ()) {        return  YES;    } Else {        return  NO;    }}

Depending on the individual needs, it can be modified to, for example: return NO;

(2) After modifying the code, the next key point is, click on the Project demo, select General, its deployment Info device Orientation only tick on the

Portrait,:

Run again, it shows the vertical screen.

Mac cocos2d-x 3.8 Setting Horizontal/Vertical screen

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.