简体   繁体   English

处理基于像素的Android游戏的不同分辨率

[英]Dealing with different resolutions for pixel based android game

I am developing a 2D platformer game for the android platform, so I don't really care about the screen DPI, but much more about the actual resolution in pixels. 我正在为android平台开发2D平台游戏,所以我并不是很在乎屏幕DPI,而是更多地关注像素的实际分辨率。 From what I've gathered on the net, there are a couple of different resolutions (and aspect ratios) present. 根据我在网上收集到的信息,目前存在几种不同的分辨率(和纵横比)。 According to my search, the two resolutions that are currently widespread are 480x320 (1.5) and 800x480 (1.666), is that right? 根据我的搜索,当前广泛使用的两种分辨率是480x320(1.5)和800x480(1.666),对吗? I'd like to target these two resolutions to reach most customers. 我想将这两种分辨率作为目标,以覆盖大多数客户。 Now, I can deal with the different aspect ratios by showing a black border of 40 pixel for the bigger display, essentialy reducing it to 720x480 pixel and a ratio of 1.5. 现在,我可以通过为较大的显示器显示40像素的黑色边框来处理不同的宽高比,然后将其本质上减少为720x480像素和1.5的比例。

The problem with my game is that it is essential for gameplay that the players see the same amount of the world on each screen. 我的游戏的问题在于,对于游戏而言,玩家在每个屏幕上看到相同数量的世界至关重要。 Otherwise, some players would get an unfair advantage. 否则,某些玩家将获得不公平的优势。 Furthermore, I trigger some events depending on the visibility. 此外,我会根据可见性触发一些事件。 For example, an enemy is only allowed to start shooting when the player starts seeing it. 例如,只有在玩家开始看到敌人时,才允许它开始射击。 Otherwise, the enemies' bullets would seem to come from nowhere. 否则,敌人的子弹似乎无处可去。

So I figured I need to either create my graphics for one resolution and scale them for the other. 因此,我认为我需要为一种分辨率创建图形,然后为另一种分辨率缩放图形。 Or I create separate graphics for each resolution. 或者我为每种分辨率创建单独的图形。 Is that right? 那正确吗? Unfortunately, both ways are suboptimal for pixel graphics. 不幸的是,这两种方法对于像素图形都不理想。

On another note: How can I restrict my game to these resolutions only (especially for the Android Market)? 另外请注意:如何将我的游戏仅限制为这些分辨率(尤其是对于Android Market)? I know about the "supports-screens" tag in the manifest, but that works depending on the effective screen-size, not the size in pixel, or am I mistaken? 我知道清单中的“ supports-screens”标签,但这取决于有效的屏幕尺寸,而不是像素尺寸,还是我弄错了? I am also interested in personal experiences of other android game developers when it comes to resolution independence. 对于分辨率独立性,我也对其他Android游戏开发人员的个人经历感兴趣。

Thanks! 谢谢!

My question would be: what do you think would do on a PC? 我的问题是:您认为在PC上会做什么? For game development, Android should be looked at much more like a PC target than a console. 对于游戏开发,应该将Android视为更像PC目标而不是控制台。 You just intrinsically need to accept that there will be some diversity of screens that you can't totally predict up-front. 您只需要从本质上接受这样一个屏幕的多样性,即您无法完全预先预测。

So I think there are two main approaches to take: 因此,我认为可以采用两种主要方法:

(1) Use a constant "display size" as if you were setting a fixed video resolution on the PC and letting the user's monitor deal with it. (1)使用恒定的“显示尺寸”,就像在PC上设置固定的视频分辨率并让用户的显示器处理它一样。 On these devices of course there is no monitor, just one fixed display, so it doesn't make sense to modify the core resolution. 当然,在这些设备上没有显示器,只有一个固定的显示器,因此修改核心分辨率没有任何意义。 Instead, you can set up the SurfaceView showing your game to have a fixed resolution, and let the platform's compositor take care of scaling it (in hardware) as it composites to the screen. 相反,您可以设置显示游戏的SurfaceView具有固定的分辨率,并让平台的合成器在将其合成到屏幕时(在硬件中)对其进行缩放。

(2) More intelligently adjust to the actual resolution of the screen you find yourself running in. Scale up or down graphics yourself to create the playing area you want. (2)更智能地调整您发现自己正在运行的屏幕的实际分辨率。自己放大或缩小图形以创建所需的播放区域。 Maybe have some different sizes of textures and select the appropriate ones for the screen resolution. 也许有一些不同大小的纹理,然后为屏幕分辨率选择合适的纹理。

You could probably also do a combination of these, where you have a couple fixed sizes you pick for the surface view depending on the total resolution available which the game can run well with. 您可能还可以将它们组合在一起,在这种情况下,您可以根据游戏可以良好运行的总分辨率为表面视图选择几个固定大小。 In either case, you can do letter-boxing as appropriate to keep your aspect ratio constant on different screens, if that is what you want. 无论哪种情况,都可以根据需要进行装箱操作,以使纵横比在不同的屏幕上保持恒定。

There are three approaches to differences in aspect ratio: 有三种解决长宽比差异的方法:

  1. Show opaque borders on some ratios ("letterboxing"). 在某些比例上显示不透明边框(“ letterboxing”)。
  2. Show more of the game world on some ratios. 以某些比例显示更多游戏世界。
  3. Don't work at all on some ratios. 在某些比例上根本不工作。

With approach (1) you waste screen space on some devices. 使用方法(1),您会浪费某些设备上的屏幕空间。 Not such a big deal for televisions, but miserable on handheld devices where screen space is limited. 对于电视来说,这不是什么大问题,但是在屏幕空间有限的手持设备上却很惨。 With approach (2) players on some devices get advantages (they can see more of the world) and disadvantages (sprites are smaller, so touch precision is harder). 使用方法(2),某些设备上的播放器可以获得优势(他们可以看到更多世界),也可以具有劣势(精灵更小,因此触摸精度更难)。 Approach (3) just sucks. 方法(3)很烂。

Obviously it depends on the details of your game which is better, but as a player I much prefer approach (2). 显然,这取决于您的游戏细节,哪一个更好,但是作为一名玩家,我更喜欢方法(2)。 The constituency who care if players on other devices get a bit of a hypothetical advantage is pretty small compared to the constituency who care if their screen is partly obscured by unnecessary black bars. 与关心是否其屏幕部分被不必要的黑条遮盖的选区相比,关心其他设备上的玩家是否能获得假定优势的选区非常小。

(Similar approaches and remarks apply to differences in resolution.) (类似的方法和说明适用于分辨率的差异。)

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

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