简体   繁体   English

Android游戏上的不同分辨率

[英]Different resolutions on Android game

how can I develop a game for different screen resolutions? 如何开发适用于不同屏幕分辨率的游戏? I have already read about Density independant pixels (dp), but I still don't know how to use them. 我已经读过有关密度独立像素(dp)的信息,但是我仍然不知道如何使用它们。 For example, what size should my View have in order to be fully displayed in every device? 例如,我的View应该具有多大的尺寸才能在每台设备上完全显示? Can I just set it to 1280dp x 800dp and start drawing things on my canvas related to this size? 我可以将其设置为1280dp x 800dp并开始在画布上绘制与此尺寸有关的东西吗?

No, since the devices not only have different density, but also different ratios. 不,因为这些设备不仅具有不同的密度,而且具有不同的比率。

The easiest way is to decide your ratio (1,667 is the most popular) and create a canvas of that size. 最简单的方法是确定您的比例(最受欢迎的比例是1,667)并创建该尺寸的画布。 Then linearly scale the height(or the width) to match the device's one, and put black rectangles on the borders. 然后线性缩放高度(或宽度)以匹配设备的高度,并在边框上放置黑色矩形。 It will work without borders in a big majority of the devices, and it will still look right on the others. 它可以在大多数设备中无国界地工作,并且在其他设备上仍然可以正常使用。 This way you have the big advantage of always knowing the relative distance between your objects. 这样,您便具有始终知道对象之间的相对距离的巨大优势。

Btw i suggest you to use a graphic engine that handles it for you (for example andengine) 顺便说一句,我建议您使用可以为您处理的图形引擎(例如andengine)

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

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