Home > database >  Is creating black bars only option for dealing different aspect ratios for my problem?
Is creating black bars only option for dealing different aspect ratios for my problem?

Time:01-12

So I'm trying to learn unity by creating simple game which all its does is ball bounces around the screen boundary and collect small white squares. (game looks like this)

However, I noticed game will create black bars on the side outside of the reference ratio that I started my project. (creates black bars)

I looked for solutions online which came down to

  1. Extend my game background (Same concept as creating black bars, right?)

  2. Create script that basically streches the black screen area(where ball bounces around) on my game.

I wanted to avoid create empty space for my game so I avoided solution 1 but solution 2 didn't seem appropriate as well since if I adjust the wall ratio depending on device some players will larger area to travel to collect white squares, which will ruin the balance between devices.

What would be the ideal way for my game without hurting the balance? The option for this would be but black bar seems way too thick.

CodePudding user response:

It seems that you have already covered most of the cases yourself.

When creating a game you will usually have a "world" which has its own coordinate system. In your case you may have a 2D space with certain width and height in which your ball is moving. The size of the space can be defined any way you want to; for instance you can define that your ball is always of size 1 and the world size can than be determined based on the level selected.

The reason I am writing this is to keep in mind that maybe you wish to keep your options open to later change the size of your world and an option to have the world size different based on selected level. It is possible to determine world size based on device size as well but that means (as you already mentioned) that your world changes based on device used which means that gameplay will not be consistent across devices.

What you are facing is a pretty standard issue among all games. I for instance remember Diablo discussing an issue with wide-screen users where monsters on far edges would not respond to player and would stay idle instead of attacking due to game mechanic expecting to react when user got "closer".

Anyway. You need to decide how you wish to show your world to the user. In your case you seem to be leaning toward a few rules:

  • You wish to show all of the world at the same time
  • You wish to use as much space as possible This sounds similar to showing an image with preserve-aspect-fit mode. So yes, you will need some borders around devices that have different aspect ratio then your world.

Another option is to use "fill" approach and your content would automatically scroll based on the movement (of your ball). Not sure if this is applicable to your game though.

Yet another way is to define that only X distance around player (ball) is always shown and your ball is always centered.

But in general it usually comes down to having some "empty" solid area. One reason may be aspect ratio but another may be newer devices (iOS specifically) will have rounded corners and other dead areas for camera and speakers. You will want to avoid those areas but still want to draw "something" there like a solid wall.

  • Related