我試着在cocos 2dx中製作遊戲。它在橫向模式下工作得非常好。我甚至在各種設備上檢查過它。但是當我切換到肖像模式時,每個場景中的精靈和節點處於不同的位置,有些甚至不可見。我正在設置與屏幕寬度和高度相關的所有內容。例如:科科斯2dx肖像模式對象位置搞砸
backgroundSprite->setPosition(Point(visibleSize.width/2 +origin.x , visibleSize.height/2 +origin.y));
加切換到肖像模式,在Xcode中,我點擊項目名稱,就到了常規選項卡,並從景觀左和景觀變化肖像權。當我試圖用
return UIInterfaceOrientationMaskPortrait;
Xcode的模擬器仍然墜毀更換
return UIInterfaceOrientationMaskAllButUpsideDown;
切換到肖像模式在cocos.org頁基本編輯RootViewController.mm的方法,給了我這個錯誤
2016-02-05 07:59:25.490 CircleGame-mobile[3192:39201] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [RootViewController shouldAutorotate] is returning YES'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110116e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010fae8deb objc_exception_throw + 48
2 CoreFoundation 0x0000000110116d9d +[NSException raise:format:] + 205
3 UIKit 0x000000010db8f52b -[UIViewController __supportedInterfaceOrientations] + 903
4 UIKit 0x000000010db7dcd7 -[UIViewController _preferredInterfaceOrientationGivenStatusBarAndDeviceAndOrientation:] + 90
5 UIKit 0x000000010da4854c -[UIWindow setRootViewController:] + 111
6 CircleGame-mobile 0x000000010c3d8563 -[AppController application:didFinishLaunchingWithOptions:] + 883
7 UIKit 0x000000010d9d11f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
8 UIKit 0x000000010d9d2397 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
9 UIKit 0x000000010d9d8cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
10 UIKit 0x000000010d9d5e7b -[UIApplication workspaceDidEndTransaction:] + 188
11 FrontBoardServices 0x0000000112673754 -[FBSSerialQueue _performNext] + 192
12 FrontBoardServices 0x0000000112673ac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
13 CoreFoundation 0x0000000110042a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x000000011003895c __CFRunLoopDoSources0 + 556
15 CoreFoundation 0x0000000110037e13 __CFRunLoopRun + 867
16 CoreFoundation 0x0000000110037828 CFRunLoopRunSpecific + 488
17 UIKit 0x000000010d9d57cd -[UIApplication _run] + 402
18 UIKit 0x000000010d9da610 UIApplicationMain + 171
19 CircleGame-mobile 0x000000010c3ec934 main + 100
20 libdyld.dylib 0x00000001105fa92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
它仍然無法正常工作。我嘗試了所做的更改,除了編輯RootViewControler.mm而不是AppController.mm。錯誤不再發生,但對象仍然未被分配 –
它應該是有效的,因爲我從一個肖像製作的遊戲中獲得了它們。那麼,你如何加載你的場景?你是從Cocos Studio加載它,還是從代碼中加載?您應該首先在空白項目上嘗試它,然後複製第一個場景,然後您應該能夠找出問題出在哪裏。 – Makalele
我做了你告訴我的並意識到了這個問題。我的父容器出現了分配問題。謝謝。我工作。 –