Corona SDK跨设备屏幕分辨率 [英] Corona SDK Cross Device Screen Resolution

查看:89
本文介绍了Corona SDK跨设备屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将是那些笨拙的问题之一,寻找一个可能不存在的答案,但这是可行的.

This is going to be one of those awkward questions looking for an answer that probably doesn't exist, but here goes.

我一直在使用Corona开发一些简单的游戏,尽管该功能似乎在我测试过的大多数物理设备上都可以很好地工作,但主要的问题是布局.我知道您不能真正为每个设备完美地构建,但是我想知道是否存在一种通用的方法来使应用程序在尽可能多的屏幕上看起来更好.我可以使用这些设备

I've been developing some simple games using Corona and whilst the functionality seems to work pretty well across most of the physical devices I have tested on, the one main issue is the layout. I know you can't really build for every single device perfectly, but I'm wondering if there is a common method to make an app look good across as many screens as possible. I have access to these devices

  • iPad 1& 2:4:3(1.33)
  • iPhone 960×640 3:2(1.5)
  • iPhone 480x320 3:2(1.5)
  • Galaxy Nexus 16:9(1.77)

据我所见,人们的目标是使用320x480作为缩放分辨率,然后让Corona放大到正确的设备分辨率(根据需要使用任何@ 2x图像),但这会导致BOX或裁切,具体取决于config.lua标度设置.虽然它确实可以正确缩放,但是拥有信箱并不好.

From what I have seen, people aim to use 320x480 as a scaled resolution and then let Corona upscale to the correct device resolution (with any @2x images as required) but this leads to letterboxing or cropping depending on the config.lua scale setting. Whilst it does scale correctly, having a letterbox isn't great.

所以我最好不要在配置文件中指定宽度和高度,而是首先使用某种屏幕检查来寻找1.33/1.5/1.77的宽高比吗?当然,从Corona SDK的整个角度来看,开发人员会使用某种典型"设置来开始任何新项目吗?

So would I be best to not specify a width&height in the config file, but instead to use some sort of screen check at first to look for 1.33 / 1.5 / 1.77 aspect ratios? Surely with the whole point of Corona SDK, there would be some sort of 'typical' setup that developers use for the start of any new project?

谢谢

推荐答案

看来,我已经根据Ansca网站上的以下论坛帖子找到了一个非常不错的解决方案:

It seems that I have found a pretty good solution based on this forum post on the Ansca website: http://developer.anscamobile.com/forum/2012/03/12/understanding-letterbox-scalling

总而言之,config.lua应该看起来像这样:

In summary, the config.lua should look like this:

application = {
    content = {
        width = 320,
        height = 480,
        scale = "letterbox",
        xAlign = "center",
        yAlign = "center",
        imageSuffix = {
        ["@2x"] = 2,
    },
    }
}

为较旧的设备创建360 * 570的背景图像. 320x480屏幕将略微裁切图像,并且可以很好地缩放以用于较旧的Android设备.

Create background images at 360*570 for older devices. 320x480 screens will crop the image slightly and it will scale nicely for older Android devices.

为iPad和iPhone视网膜创建1140 * 720的背景图像-同样,这些图像将在Android上缩放,并在iOS上略有裁剪.

Create background images at 1140*720 for iPad and iPhone retina - again these will scale on Android and be slightly cropped on iOS.

例如,通常您将创建一个320x480的图像并使用以下命令显示该图像:

As an example, where you would normally create a 320x480 image and display it with:

local bg = display.newImageRect("bg.png",320x480)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2

..而是创建360x570背景并使用以下代码:

.. instead create a 360x570 background and use the following code:

local bg = display.newImageRect("bg.png",360x570)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2

这只是一个摘要,因此请查看链接以获取更多详细说明.

This is just a summary, so check the link for more detailed instructions.

这篇关于Corona SDK跨设备屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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