Disable orientation for the game ? - Run only landscape mode

Disable orientation for the game ? - Run only landscape mode
0.0 0



Is there a way to disable the rotation to make it run only in landscape mode?

My game is html based and i want the game to run only in landscape mode rather portrait.

Is there a way to do this?


I’m also very interested in this.


Do you have any idea on this?

Do you think is there no solution to this in cocos?


I have no idea, but since there are methods that handle device rotation within cocos, I hope it can be done easily.

We’ll just have to wait for one of the devs to spot this thread and shed some light on the matter.



In javascript level, we can’t really force the orientation of your browser, I don’t believe it’s possible. But I think there are some way to achieve a notification view when the orientation is not preferred.

First of all, you can use cc.EGLView.getInstance().setResizeCallback(callback) to detect a orientation change, in the callback such code can detect which is the current orientation

switch (window.orientation) {
    case cc.UIInterfaceOrientationLandscapeRight://-90

    case cc.UIInterfaceOrientationLandscapeLeft://90

    case cc.UIInterfaceOrientationPortraitUpsideDown://180

    case cc.UIInterfaceOrientationPortrait://0

Then you can force user to rotate back their device:
Pause your director and show a message layer on your game, you can use a text message or a simple big image of device rotation.

Hope this helps



Hi @ pandamicro,
I am in need of landscape mode in my Html game…Can you please tell where to use the code which u have mentioned in the above post??