Cocos2d - Setting Device/Screen Orientation

前端 未结 6 965
情话喂你
情话喂你 2021-01-15 17:31

I am new to the cocos2d API and have noticed that there are a few ways to set the screens orientation within the templates. I have not been able to figure out the correct wa

6条回答
  •  离开以前
    2021-01-15 18:35

    The answer here has changed with cocos2d 2.0, as CCDirector is now a ViewController on iOS:

    CCDirector no longer supports device orientation. All autorotation and device orientation is handled by RootViewController now. Fortunately, [[UIDevice currentDevice] orientation] can be used in place of [[CCDirector sharedDirector] deviceOrientation]. The enums are the same, except that they begin with UI instead of CC.

    Forcing a specific orientation is a simple matter of returning YES only to the desired orientation in the RootViewController method shouldAutorotateToInterfaceOrientation.

    Choosing between Cocos2D v1.x & 2.x and Tips for updating to Cocos2D 2.0 at learn-cocos2d.com

提交回复
热议问题