Game getting zoomed when in portrait mode

Game getting zoomed when in portrait mode
0.0 0

#1

I am building a mobile game with Cocos Creator.
The game canvas is 1136x640

I have set Fit Height to true

I want players to play the game in landscape or portrait mode.
When I view the game in landscape mode it looks great.

But when I check the game on portrait mode. It does not look right. Seems the game is zoomed in.

Is there a way to keep the game in same zoom regardless of the orientation of the game.
Suppose I define a active area where all the action takes place, is there a way to view that area regardless of the orientation.

What is the standard method to handle this situation?

Appreciate any help you can provide…


#2

Surely, there is a way to overcome this issue…
can anyone provide some advice?


#3

How do you adjust the layout in portrait mode? You said you wanted active area
What Cocos is doing is mantaining the Height, because you have set Fit Height to true. I think that what you want is to Fit Width

If you set both Fit Height and Fit Width, you may have distortion, but the canvas will always be shown entirely.

A more complex approach would be to change the Resolution Policy in your script, depending on your orientation, refer to http://docs.cocos.com/creator/api/en/classes/Canvas.html#fitheight.

cc.Canvas.instance.fitHeight = false;
cc.Canvas.instance.fitWidth = true;

Are you developing for web or native? You can also check http://docs.cocos.com/creator/api/en/classes/View.html#setresizecallback
I haven’t tested this function to change the resolution policy,but it should work

cc.View.setResolutionPolicy(cc.ResolutionPolicy.FIXED_WIDTH);

But I think there is no need to you change the policy by script. It is easier to use Widgets, and, by what you want, use fixed Width instead of fixed heigth. Please, refer to http://docs.cocos.com/creator/manual/en/ui/. Auto fit for multi-resolution