yandeu / phaser3-optimal-resolution

18 stars 5 forks source link

Handling different aspect ratios? #1

Closed Rob-bie closed 4 years ago

Rob-bie commented 4 years ago

Stumbled upon this repo through some discussion that's happening on Discord. I use similar methods for designing my games for mobile. I see that you're using a base resolution of 640x360 and have assets saved out at 4x, 3.5x, etc. Because the scale mode is set to FIT you're going to see letterboxing on any device that doesn't have an aspect ratio of 16:9. What's your strategy for handling this case? One trick that I use when applicable is making the canvas background transparent and using a large css background (or better yet, a background that tiles) to make it appear that the device's entire display is being utilized.

Another option is using the device's full resolution widthxdpr, heightxdpr (or some fraction of the dpr for performance) but then depending on the game a user on a larger device might be seeing more of the game which could give them an advantage. I think this is more of a ramble than a question at this point but this is a topic I have been thinking about a lot recently.

yandeu commented 4 years ago

No you are wrong. I draw my assets in 360*640@4 but this strategy uses the entire screen width and height times DPR. When you code your game you simply have to keep in mind to place your sprites relative to the scene.

Rob-bie commented 4 years ago

Ah, I misread. That makes much more sense. Thanks!