How can I lock screen orientation on mobile?

we want to start and keep the game in landscape mode even the phone is in portrait,and ignore the phone orientation change.

Do you mean this kind of issue ?
Model stretch after orientation change on IOS

I don’t believe you have control of that at the browser level. One solution that a previous user used was to detect if the phone was in portrait mode, paused the game and asked the user to rotate back to landscape.

Going to fullscreen might lock the rotation?

You need the Screen Orientation API. However, it is not supported on iOS. Only in Chrome (and Firefox) for Android.

1 Like

You can do this on iOS “kinda” by using CSS to rotate the canvas using a media query but there are issues of doing that because iOS will show the address bar in one rotation and not the other by default. You also have to resize the canvas using an event handler for window.resize

A slightly better way is to overlay a graphic of a phone being rotated if the orientation is wrong. Again you can use a media query to make this overlaying div/image visible when the device is in portrait.

sorry for late reply,my issue is differert from yours,but thanks anyway.

thanks,finally by changing engine code we sloved this problem.

thanks for your reply,we have get this problem sloved.

we adopt your solution and change the engine code corresponding , we finally get it work,thanks

But if you are using engine only and on iOS, when you rotate the phone multiple times, the graphics will be stretched. I still finding a good way to solve this issue. What I am doing is add an iframe outside the canvas.

How to do with this?Can you share a project demo for me?thx:)