phaser icon indicating copy to clipboard operation
phaser copied to clipboard

SHOW_ALL gives incorrect dimension meaning scrolling is needed

Open happinesssam opened this issue 10 years ago • 4 comments

  • A bug in the API

I have been trying to build a full screen mobile game using the full screen mobile template. My game is 600x400 and I have been finding that the game is not being scaled correctly meaning that the bottom of the game is cut off and needs to be scrolled to. My assumption was that SHOW_ALL should show all of the app without the need for scrolling as long as the window is within scale.setMinMax bounds.

I have made an example using the template http://utterlysuperb.com/dev/js/fsm/

I think I may have tracked down the issue, or at least I've found a hack to workaround it. I think the issue is with Element.getBoundingClientRect() which is used in the ScaleManager's getParentBounds function to set the bounds which is then used in setShowAll. This returns the dimensions of the element, not the viewable area, meaning the canvas isn't getting scaled.

All I did was to override ScaleManager.getParentBounds so that it ignores getParentBounds and just uses dom.visualBounds and this seems to fix the problem for me. I have made an example with this override http://utterlysuperb.com/dev/js/fsm2/

I don't know if this will mess up other display modes or if I have missed something obvious but I hope this makes sense.

happinesssam avatar Aug 01 '16 09:08 happinesssam

You might want to add

this.scale.windowConstraints.bottom = 'visual';

when you set up your scale manager, this will make sure that the game won't appear past the bottom, so you don't have t scroll

Doc link

AleBles avatar Aug 08 '16 14:08 AleBles

Thanks, that's obviously miles better than my just hacking out part of the code.

I only skimmed it and didn't notice that '' was considered a valid value. I assumed it would default to visual. I still think that it might be worth reviewing the template, and maybe highlighting that this option is needed.

happinesssam avatar Aug 08 '16 15:08 happinesssam

I've been banging my head against the desk for days about this issue. Thanks!

jackfreak avatar Sep 12 '16 04:09 jackfreak

Thank you for taking the time to open this issue. However, official support for Phaser 2 has now ended as we focus on preparing Phaser 3 for beta release. In a bid to keep the project tidy, and avoid confusion, we are closing all v2 related issues.

This does not mean your issue won't be looked-at. In November 2016 the Phaser CE (Community Edition) project began. The aim of Phaser CE was to allow the community to continue v2 development. Since then it has gained significant traction, with many updates and releases.

If you are still interested in having your issue investigated we strongly recommend testing the latest Phaser CE release. And only if the problem persists, opening an issue on the Phaser CE repo.

photonstorm avatar Apr 20 '17 12:04 photonstorm