在 Android 上创建与分辨率无关的游戏

发布于 2024-11-15 01:06:53 字数 248 浏览 5 评论 0原文

我对 Android 游戏开发(以及一般的 Android 开发)还很陌生。

当我为我的第一款游戏创建背景时,我的第一个问题出现了:我应该选择哪种尺寸? 例如,如果我选择 800x480,它在其他分辨率下显示效果是否良好? 那我的主角呢?如果我让它每帧移动 5 像素(我已经知道如何使其与 fps 无关,这只是一个例子),那么在 320 像素宽度的屏幕上移动 5 像素与在 800 像素宽度的屏幕上移动 5 像素是不一样的。 对此有什么建议吗?

谢谢

I'm quite new to Android game development (and Android development in general).

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?
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.
Any advices on this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦断已成空 2024-11-22 01:06:53

您应该为您希望支持的每种屏幕密度拥有单独的资源文件。

You should have separate resource files for each of the screen densities you wish to support.

蔚蓝源自深海 2024-11-22 01:06:53

选择您计划进行开发的设备本机支持的背景大小,并在项目接近尾声时担心支持非本机分辨率或添加其他分辨率的资源。不要陷入杂草之中。

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.

私藏温柔 2024-11-22 01:06:53

正如 @PaulSonier 所说,直到最后都不要担心支持多个分辨率。

目前仅在一台设备上进行开发,并尽可能使用“dp”或“dip”单位。这将使最终更容易支持多种屏幕尺寸和密度

至于背景,请考虑使用9-patches

As @PaulSonier said, don't worry about supporting multiple resolutions until the end.

For now just develop on one device and use 'dp' or 'dip' units whenever possible. This will make it easier at the end to support multiple screen sizes and densities.

As for the background, consider using 9-patches.

删除会话 2024-11-22 01:06:53

对于您想要支持的每种分辨率,您都应该有一组单独的图形。如果您确实想覆盖所有当前设备并在每台设备上都拥有清晰锐利的图形,并且希望确保宽高比不会使您的游戏在某些设备上看起来很奇怪,那么您需要准备您的资源采用以下分辨率和比例:

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

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

最好的解决方案是至少绘制所有全屏图像2733x2134 像素,然后按比例缩小。好吧,您可以缩小图像,如果您有文本,最好使用较小的字体大小并将其放在图像上。您可以在运行时执行此操作或提前预渲染文本。您可以使用 ImageMagick 自动执行 6 种不同尺寸的所有操作,这样您就不必手动执行此操作。

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%
  2. 1024x800 scale 120%
  3. 1280x1024 scale 160%
  4. 1536x1152 scale 192%
  5. 1920x1200 scale 240%
  6. 2560x1600 scale 320%

Source: 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. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文