Question

I'm trying to do this with changing files

GameConfig.h:

#define GAME_AUTOROTATION kGameAutorotationNone

And App delegate:

//#if GAME_AUTOROTATION == kGameAutorotationUIViewController

    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
//#else

//[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];

//#endif

App turns to Portrait mode, but Box2d bodies forced gravity to right

Was it helpful?

Solution

You should edit the file RootViewController.m at line 88:

return (UIInterfaceOrientationIsLandscape(interfaceOrientation));

and change it to:

return (UIInterfaceOrientationIsPortrait(interfaceOrientation));

This setting only takes effect when GAME_AUTOROTATION is defined as kGameAutorotationUIViewController, in GameConfig.h.

///////

OTHER TIPS

in case anyone need I realize that this is an old topic, but in case anyone comes across this problem in the future, here is my solution:

In the accelerometer function of HelloWorldLayer.mm the gravity is set with this line

b2Vec2 gravity( -accelY * 10, accelX * 10);

In order to simulate the desired effect in portrait mode, the line must be re-ordered to:

b2Vec2 gravity( accelX * 10, accelY * 10);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top