About screen orientation

I design a game
Usually horizontal screen
Some specific scenes and levels require portrait screen

Use composer.gotoScene() to enter the scene become portrait screen, back previous scene become horizontal screen
Can this be done?

That’s doable at least using Android’s own API, but I don’t know there are Lua calls for that in Solar2D.

I would, however, advice against that. If the user has to constantly flip their device around, it may hurt the overall gameplay experience. I would recommend finding out how to implement the entire game using one orientation.

If you really want to implement this, I think you could just write the scenes as if one of them was flipped around. If you want to do something dynamic, then you can get around the missing API in Solar2D by using accelerometer to determine the device’s orientation and use its information to flip the display groups around.

I have an idea but a question

Use composer.gotoScene() to new scene
Set self.view rotation 90
But when the device is a portrait screen, there will be a chance to switch “landscapeLeft” or “landscapeRight”
Turn the screen upside down

When using portrait screen,
How to lock the direction switch?
When use landscape unlock direction to landscape left or landscape right.


You may want to try this plugin to “lock” the orientation,


PS> I have not tried it myself yet.

Thank you :smiley: