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