eric.mitchell
eric.mitchell

Reputation: 8855

Disable autorotation in Cocos2d

I have a game that uses the accelerometer to move the player. For this reason, I would like to disable autorotation so that the screen will not be accidentally rotated during play. I am pretty new to Cocos2d, and I'm not exactly sure how to do this. Returning NO in the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

method in the app's delegate and using

[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];

in the layer works, but then a black rectangle appears on the right 1/3 of the screen. What am I doing wrong?

Upvotes: 0

Views: 1679

Answers (1)

JeanLuc
JeanLuc

Reputation: 4893

If you're using the cocos2d template look for the file GameConfig.h, otherwise search for GAME_AUTOROTATION and define it to kGameAutorotationNone

#define GAME_AUTOROTATION kGameAutorotationNone

Upvotes: 6

Related Questions