在Cocos2d中禁用自动旋转

eri*_*ell 0 cocos2d-iphone ios

我有一个使用加速度计来移动玩家的游戏.出于这个原因,我想禁用自动旋转,以便在播放期间不会意外地旋转屏幕.我对Cocos2d很新,我不确定如何做到这一点.回归NO

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
Run Code Online (Sandbox Code Playgroud)

应用程序委托和使用中的方法

[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];
Run Code Online (Sandbox Code Playgroud)

在图层工作,但然后在屏幕的右1/3出现一个黑色矩形.我究竟做错了什么?

Jea*_*Luc 6

如果您正在使用cocos2d模板,请查找GameConfig.h文件,否则搜索GAME_AUTOROTATION并将其定义为kGameAutorotationNone

#define GAME_AUTOROTATION kGameAutorotationNone
Run Code Online (Sandbox Code Playgroud)