简体   繁体   English

在Android上创建分辨率独立游戏

[英]Create resolution independent game on Android

I'm quite new to Android game development (and Android development in general).我对 Android 游戏开发(以及一般的 Android 开发)还很陌生。

My first question came when I was creating the background for my first game: which size should I choose?当我为我的第一款游戏创建背景时,我的第一个问题出现了:我应该选择哪种尺寸? If I choose 800x480 for example, will it show good on any other resolutions?例如,如果我选择 800x480,它会在任何其他分辨率上显示良好吗? And what about my main character?而我的主角呢? If I make it move 5px/frame (I already know how to make it fps independent, it's just an example), it's not the same to move 5 pixels on a 320px-width screen than on a 800px-width one.如果我让它移动 5 像素/帧(我已经知道如何让它独立于 fps,这只是一个例子),在 320 像素宽度的屏幕上移动 5 像素与在 800 像素宽度的屏幕上移动 5 像素是不一样的。 Any advices on this?对此有何建议?

Thanks谢谢

You should have separate resource files for each of the screen densities you wish to support.对于您希望支持的每个屏幕密度,您应该有单独的资源文件。

Pick the background size that's supported natively on the device you plan on developing on, and worry about supporting non-native resolutions or adding resources for other resolutions when you're near the end of the project.选择您计划开发的设备本机支持的背景大小,并在项目接近尾声时担心支持非本机分辨率或为其他分辨率添加资源。 Don't get bogged down in the weeds.不要陷入杂草之中。

You should have a separate set of graphics for each of the resolutions you want to support.对于要支持的每种分辨率,您都应该有一组单独的图形。 If you really want to cover all the current devices and have the crisp and sharp graphics on every one of those and you want to make sure that the aspect ratio doesn't make your game look weird on some devices, you need to prepare your assets in the following resolutions and scales:如果你真的想覆盖所有当前的设备并在每一个设备上都拥有清晰锐利的图形,并且你想确保纵横比不会让你的游戏在某些设备上看起来很奇怪,你需要准备好你的资源在以下分辨率和比例:

  1. 854x600 scale 100% 854x600 比例 100%
  2. 1024x800 scale 120% 1024x800 比例 120%
  3. 1280x1024 scale 160% 1280x1024 比例 160%
  4. 1536x1152 scale 192% 1536x1152 比例 192%
  5. 1920x1200 scale 240% 1920x1200 比例 240%
  6. 2560x1600 scale 320% 2560x1600 比例 320%

Source: http://bigosaur.com/blog/31-android-resolutions-definite-answer资料来源: http://bigosaur.com/blog/31-android-resolutions-definite-answer

The best solution is to draw all full-screen images at least 2733x2134 pixels and then scale it down.最好的解决方案是绘制至少 2733x2134 像素的所有全屏图像,然后将其缩小。 Well, you can scale down images, if you have text, better to use smaller font size and put it over the image.好吧,您可以缩小图像,如果您有文字,最好使用较小的字体并将其放在图像上。 You can do this at run-time or pre-render the text in advance.您可以在运行时执行此操作或提前预渲染文本。 You can use ImageMagick to automate all that for 6 different sizes so you don't do it manually.您可以使用 ImageMagick 为 6 种不同尺寸自动执行所有操作,因此您无需手动操作。

As @PaulSonier said, don't worry about supporting multiple resolutions until the end.正如@PaulSonier 所说,直到最后都不要担心支持多种分辨率。

For now just develop on one device and use 'dp' or 'dip' units whenever possible.现在只需在一台设备上开发并尽可能使用“dp”或“dip”单位。 This will make it easier at the end to support multiple screen sizes and densities .这将使最终更容易支持多种屏幕尺寸和密度

As for the background, consider using 9-patches .至于背景,考虑使用9-patches

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM