使用电晕sdk的不同屏幕尺寸 [英] different screen sizes with corona sdk

查看:87
本文介绍了使用电晕sdk的不同屏幕尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用corona sdk制作我的第一个iPhone游戏,希望它能在尽可能多的设备(手机+平板电脑)上运行.但是,我不确定如何处理不同的屏幕尺寸和分辨率.我使用电晕模拟器为iPhone 5开发了游戏,并且在该设备上运行良好.当我在分辨率较低的设备(例如iPhone 4)上尝试使用该设备时,每边都有2个黑色矩形.我尝试创建2个具有不同分辨率的不同背景,并将其添加到config.lua中.

I am making my first iphone game using corona sdk and would like it to run on as many devices as possible (phones + tablets). However I am not sure how to deal with different screen sizes and resolutions. I developed my game for the iPhone 5 using corona simulator and it works fine on that device. When I tried it on lower resolution devices like the iPhone 4 I get 2 black rectangles on each side. I tried creating 2 different backgrounds with different resolutions and added this in my config.lua:

imageSuffix = {
       ["@2x"] = 2
}

但是,这似乎并没有改变任何东西...我不确定在config.lua文件的内容中应该设置什么高度和宽度,以及应该为背景设置什么高度和宽度.如果这些问题很愚蠢,我很抱歉,我才刚刚开始. 预先感谢!

However this does not seem to change anything... I am not sure what height and width I should set in content in the config.lua file and what heights and widths I should set for the backgrounds. I am sorry if these questions are stupid, I am just starting. Thanks in advance!

推荐答案

听起来您需要完全阅读配置文件和动态缩放.

It sounds like you need to fully read up on config files and dynamic scaling.

问题有点广泛,因此,我建议您阅读有关最终配置/使配置现代化" .

The question is a little to broad as such I suggest you read this article about "the ultimate config/modernizing the config".

某些屏幕更宽,而其他屏幕更窄.如果我们采取 分辨率超出等式,因此更易于可视化屏幕. 电晕使您可以轻松使用以下方法将分辨率从照片中取出 动态缩放.通过动态缩放,您可以使用一组通用的 屏幕坐标和Corona会自动缩放文本和 不同分辨率屏幕的图形.它可以向上缩放或 向下,具体取决于您的起点.它也可以替代 需要放大的高分辨率图像.这是所有的了 由项目文件夹中名为config.lua的Lua文件管理.

Some screens are wider while others are more narrow. If we take resolution out of the equation, its easier to visualize the screens. Corona makes it easy to take resolution out of the picture using Dynamic Scaling. With Dynamic Scaling, you can use a common set of screen coordinates and Corona will automatically scale the text and graphics for different resolution screens. It can scale upwards or downwards depending on your starting point. It also can substitute higher resolution images when it needs to scale up. This is all managed by a Lua file in your project folder called config.lua.

由于可用的分辨率差异很大,因此使用 每个设备的比例尺相同.如果您使用的是iPhone没关系 320×480的3GS或1536×2048的Retina iPad,位置(0,0) 代表左上角和(320,480),以垂直肖像显示 模式,是右下角.屏幕中心为(160,240). 在这种情况下,每个点在较低分辨率的设备上都是一个像素 例如3GS,其原始屏幕分辨率为320×480,而 在Retina iPad上,每个点是四个像素.不用担心数学 — Corona会为您处理.

Since available resolutions vary considerably, it’s helpful to use the same scale for each device. It doesn’t matter if you’re on an iPhone 3GS at 320×480 or a Retina iPad at 1536×2048, the location (0,0) represents the top-left corner and (320,480), in vertical portrait mode, is the bottom-right corner. The screen center is (160,240). Each point, in this case, is one pixel on a lower-resolution device like the 3GS, which has a native screen resolution of 320×480, while each point is four pixels on a Retina iPad. Don’t worry about the math — Corona will handle it for you.

来源: http://coronalabs.com /blog/2012/12/04/the-ultimate-config-lua-file/

这是通过创建一个配置文件来进行的,该配置文件充分利用了动态缩放和图像缩放功能.

This goes through the creation of a config file that fully utilize the dynamic scaling and image scaling.

local aspectRatio = display.pixelHeight / display.pixelWidth
application = {
   content = {
      width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),
      height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),
      scale = "letterBox",
      fps = 30,

      imageSuffix = {
         ["@2"] = 1.8,
         ["@4"] = 3.6,
      },
   },
}

这篇关于使用电晕sdk的不同屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆