How to set HelloWorld Template 0.99.5 to Portrait Orientation?
-
29-09-2019 - |
Pergunta
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
Solução
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
.
///////
Outras dicas
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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow