Configuration Options配置選項


Corona projects may be configured with two optional files: config.lua and build.settings, each of which use Lua table syntax and should be located in the project directory. The build.settings file contains instructions for the build process, and config.lua is compiled into your project and accessed at runtime.
Corona項目可能配置了兩個可選文件:config.lua和build.settings,每個表使用Lua語法和應位於項目目錄。該文件包含指令build.settings生成過程,並 config.lua編譯到你的項目和訪問在運行時。


Runtime Configuration: config.lua
運行時配置:config.lua


Several runtime properties can be specified in a config.lua file, which can be included in the project directory. This section discusses the currently available options.
幾個運行時屬性可以指定在一個 config.lua文件,它可以包含在項目目錄。本節討論了目前可用的選項。


Dynamic Content Scaling
動態內容縮放


(For a detailed introduction to this feature, see this blog post.)
(有關詳細介紹了這個功能,看到這個博客帖子。)


Content scaling features are useful for multi-screen development. For example, iPhone projects designed for a 320 pixel wide screen can be upscaled to the 480 pixel wide screen on Android devices, making porting much easier, since code and assets do not need to be revised.
內容縮放功能是有用的多屏的發展。例如,iPhone的項目設計為320像素寬屏幕可放大的480像素的寬屏幕Android設備,使移植容易得多,因為代碼和資產並不需要加以修訂。


Also, Corona now targets iOS 4.0 in iPhone builds (while remaining iOS 3.0-compatible). This means that pre-iPhone 4 content will no longer upscale automatically to the larger iPhone4 screen resolution. As a result, content scaling will generally be required in new iPhone apps.
此外,現在的目標的iOSCorona在iPhone4.0版本(而其餘的iOS3.0兼容)。這意味著,前iPhone4內容將不再自動高檔大iPhone4屏幕分辨率。因此,內容比例一般都需要在新的iPhone應用程序。


The basic idea behind dynamic content scaling is that you can tell Corona that your content was originally authored for a particular screen size. Then you can choose how your app should be scaled if it runs on a device whose physical screen size is different from the original.
背後的基本思想動態內容縮放是你可以告訴您的內容Corona最初創作的一個特定的屏幕尺寸。然後你可以選擇你的程序應該如何縮放,如果它運行在一個物理設備,其屏幕尺寸從原來的有所不同。


To activate dynamic content scaling, create a config.lua file (see below) and use a scale other than "none", as shown below.
要激活動態內容縮放,創建一個 config.lua文件(見下文),並使用其他的規模比“無“,如下圖所示。


Example:


-------------------------------
application =
{
        content =
        {
                width = 320,
                height = 480,
                scale = "letterbox"
        },

-----------------------
Note 注意:
If you are building an application to run on a single device then it is not necessary to specify any content height, width, or scaling options.
如果您正在構建一個應用程序運行在一台設備則沒有必要指定任何內容的高度,寬度或縮放選項。


If your application does support running on devices with different screen dimensions, the width and height MUST be the value of the target device in portrait orientation. 
如果您的應用程序不支持的設備上運行的不同屏幕尺寸,寬度和高度必須是價值目標設備在縱向方向。


These values are not dependent on the orientation mode of your application. If your app runs in landscape mode, you still set these values to the portrait width and height. 
這些值不依賴於你的應用方向模式。如果你的程序運行在橫向模式下,你仍然設置這些值的肖像寬度和高度。


Use the "orientation" setting in the build.settings file to define the orientation modes supported by the application.
使用“方向“設置在build.settings文件來定義的方向所支持的應用模式。


Note 
about trailing commas
In the examples on this page you'll notice that the tables have commas after the last entries. These are referred to as trailing commas. In Lua, trailing commas are optional, but always valid. Source: Programming in Lua, 2nd Edition by Roberto Ierusalimschy
注意:
關於尾隨逗號
在此頁上的例子,你會發現,現在情況發生了逗號後,最後條目。這些被稱為尾隨逗號。在Lua中,尾隨逗號是可選的,但始終有效。來源:編程 Lua中,第二版由Roberto Ierusalimschy


The value of "content" should be a table containing the following key-value pairs:
該值“內容“應該是一個包含以下關鍵值對:


width (number) - the width, in pixels, of the original target device (in portrait orientation)
寬度(數字) -的寬度,以像素為單位,原來的目標設備(縱向)


height (number) - the height, in pixels, of the original target device (in portrait orientation)
高(數字) -的高度,以像素為單位,原來的目標設備(縱向)



scale (string) - the type of auto-scaling, from one of:
量表(字符串)- 類型的自動縮放,從一個:


"none" - turns off dynamic content scaling
“無“- 關閉動態內容縮放


"letterbox" - uniformly scales up content as much as possible, while still showing all content on the screen. 
“信箱“ -統一尺度註冊內容盡可能,而仍然顯示在屏幕上的所有內容。
This is similar to watching a widescreen DVD on a non-widescreen TV set, except that you can use offstage content to fill the "bleed" areas rather than displaying black bars.
這類似於觀看寬屏 DVD在非寬屏電視,但你可以用台下內容來填充“流血“的地區,而不是顯示黑條。


"zoomEven" - uniformly scales up content to fill the screen, while preserving aspect ratio. Some content may appear offscreen, if the new screen has a different aspect ratio
“zoomEven“ -均勻可擴展至內容來填充屏幕上,同時保持高寬比。有些內容可能會出現屏幕外,如果新的屏幕上有一個不同的寬高比


"zoomStretch" - non-uniformly scales up content to fill the screen. All content will remain onscreen, but it may be stretched vertically or horizontally.
“zoomStretch“ -非均勻可擴展至內容來填充屏幕。所有內容將保持在屏幕上,但它可能是水平或垂直拉伸。


The content width and height allow you to choose a virtual screen size that is independent of the physical device screen size. This will generally be the size of your original target device -- which often means the original iPhone dimensions of 320 x 480, as in the SDK code samples.
寬度和高度的內容讓您選擇一個虛擬屏幕大小是獨立於物理設備的屏幕大小。這通常會在你原來的大小目標設備- 這往往意味著原有的iPhone尺寸為 320× 480,作為 SDK中的代碼示例。


You are then free to code as if you are positioning objects to the virtual screen. Touch events (and other hit events) will be remapped to the correct location on all screens when dynamic content scaling is active.
然後,您可以自由地代碼,如果你是定位對象的虛擬屏幕。觸摸事件(和其他襲擊事件)將被重新映射到正確的位置時,屏幕上的所有動態內容縮放活躍。


These virtual (i.e., content) dimensions are accessible via display.contentWidth and display.contentHeight. Because of this, the concept of stage width and height, e.g., display.stageWidth and display.stageHeight, has been deprecated in favor of content width and height.
這些虛擬(即內容)的尺寸都可以通過 display.contentWidth和display.contentHeight。正因為如此,這一概念的舞台寬度和高度,如display.stageWidth和display.stageHeight,已被否決贊成內容的寬度和高度。


By default, if no content size is specified, the content width and height returned will be the same as the physical screen width and height of the device. If you are specify a different content width and height in config.lua, the content width and height will take on those values.
默認情況下,如果沒有指定內容的大小,寬度和高度的內容將返回相同的物理屏幕的寬度和高度的裝置。如果您指定一個不同內容的寬度和高度config.lua,寬度和高度的內容將在這些價值觀。


When a scale is set in config.lua, the content will be rescaled to fit the screen. As far as your code is concerned, however, positions should still be specified in terms of the virtual screen coordinates.
當一個規模是集config.lua,內容將被重新調整以適應屏幕。至於你的代碼來說,然而,職位仍然應該在條款中指定的虛擬屏幕坐標。


For example, in the "Fishies" sample code (SampleCode/Graphics/Fishies), there is a config.lua file in which the content width is 320, the height is 480, and the scale is "zoomEven". If you were to view this in iPad, all the content (including the background image and the images of the fish) would be scaled to fit the iPad's screen size (1024x768) even though the images were intended for the smaller iPhone screen (320x480).
例如,在“Fishies“示例代碼(SampleCode/圖形 / Fishies),有一個 config.lua文件,其中內容的寬度為 320,高度為480個,規模是“zoomEven“。如果你要查看此在iPad,所有的內容(包括背景圖片和圖像的魚)將調整為適合 iPad的屏幕尺寸(1024 × 768),即使這些照片被用於較小的iPhone屏幕(320x480) 。


Depending on which dynamic scaling mode is used, and the aspect ratio of the device used to view the content, some of the original content may be scaled in such a way that portions are offscreen. Therefore, display.viewableContentWidth and display.viewableContentHeight have also been provided. These properties give you the currently viewable area of the screen, within the coordinate system of the original content. The Fishies sample leverages this so that the fish continue to swim only on the visible portions of the virtual screen.
根據哪個動態縮放模式時,和長寬比的設備用於查看的內容,一些原來的內容可能被縮小在這樣一種方式,部分是離屏。因此,display.viewableContentWidth和display.viewableContentHeight也已提供。這些屬性使您目前的屏幕可視區域內的坐標系統中的原始內容。樣品的Fishies利用這一點以便繼續游泳的魚只在可見部分的虛擬屏幕。


Dynamic Content Alignment動態內容的對齊方式

By default, dynamically scaled content is centered when shown on different screens. For example, in "letterbox" scaling mode, any additional screen area will be evenly divided between both sides, and in "zoomEven" mode, the area cropped will be the same on both sides.
默認情況下,中心內容是動態縮放時,顯示在不同的屏幕。例如,在“信箱“縮放模式下,任何額外的屏幕面積將是雙方平分,並在“zoomEven“模式,該地區將出現同樣的兩側。


However, there are cases where you might not want the content to be centered. For example, when scaling from the iPhone to the taller and skinnier screen of the Droid, you may not want the additional screen area at both the top and the bottom. Instead, you may want all of the added area shown the bottom, if your design features a navigation bar that should be aligned with the top of the screen.
然而,在一些情況下,您可能不希望內容居中。例如,在縮放時從 iPhone的屏幕高和瘦對 Droid,你可能不希望在更多的屏幕區域的頂部和底部。相反,你可能需要添加的所有區域中顯示的底部,如果您的設計採用了導航欄,應與頂部的屏幕。


For such cases, you may optionally specify the content alignment in both the x- and y-directions:
對於這種情況,你可以選擇指定內容的對齊方式在x和y方向:

application =
{
        content =
        {
                width = 320,
                height = 480,
                scale = "letterbox",
                xAlign = "left",
                yAlign = "top"
        },



xAlign

A string that specifies the alignment in the x-direction for the position of the reference screen (which may be scaled) relative to the physical screen. It can be one of the following values:
xAlign


一個字符串,指定路線在x方向的位置的​​參考屏幕(可縮放)相對於物理屏幕。它可以是以下值:


*"left"
*"center" (Default)
*"right"


yAlign

A string that specifies the alignment in the y-direction for the position of the reference screen (which may be scaled) relative to the physical screen. It can be one of the following values:
一個字符串,指定路線在y方向的位置的​​參考屏幕(可縮放)相對於物理屏幕。它可以是以下值:
*"top"
*"center" (Default)
*"bottom"


Note
previous versions of Corona defaulted to left/top alignment rather than centered alignment, so you can restore the older behavior by setting xAlign to "left" and yAlign to "top" in your config.lua file.
以前版本的Corona默認為左/頂端對齊,而不是居中對齊,這樣你就可以恢復舊的行為設定 xAlign“左“和yAlign到“頂“在你的config.lua文件。


Dynamic Content Properties動態內容屬性

A number of methods are exposed within Lua to help you work with scaled content:
一個數字的方法暴露在Lua中,以幫助您的工作內容與規模:


display.contentWidth
By default, this is the same as the physical screen width in pixels. If config.lua specifies a reference width, it takes on that value. For example, this would return 320 in the above examples. This is referred to as the "reference screen width" below.
默認情況下,這是一樣的物理屏幕的寬度,以像素。如果config.lua指定一個寬度,它需要這個值。例如,這將返回320以上的例子。這被稱為“參考屏幕寬度“下面。


display.contentHeight
By default, this is the same as the physical screen height in pixels. If config.lua specifies a height it takes on that value. For example, this would return 480 in the above examples. This is referred to as the "reference screen height" below.
默認情況下,這是一樣的物理屏幕的高度,以像素。如果config.lua指定高度需時該值。例如,這將返回480以上的例子。這被稱為“參考屏幕高度“下面。


display.viewableContentWidth


display.viewableContentHeight


Returns the width and height of the viewable content, which may be different than the reference content dimensions if the target screen has a taller or wider aspect ratio.
返回的寬度和高度的可視內容,這可能是不同的尺寸比參考的內容,如果屏幕上有一個更高的目標或更大的寬高比。


Note that these values are expressed in reference screen units: for example, content with a reference size of 320 x 480 upscaled to iPad using "zoomEven" will be cropped at the top and the bottom, and therefore the viewableContentHeight will return a value like 426 rather than the original value of 480. This lets you detect the "safe zone" for your content when deploying across multiple screens.
請注意,這些值是在參考屏幕單位表示:例如,內容與參考尺寸為 320× 480上變換到ipad使用“zoomEven“將出現在頂部和底部,因此viewableContentHeight將返回值,如426而不是原來的值480。這可以讓你發現的“安全區“為您的內容時,部署在多個屏幕上。


Note注意:


There is currently a known bug where these methods may return misleading values in "letterbox" scaling mode; this will be fixed in a future release.
目前有一個已知的錯誤而這些方法可能誤導返回值“letterbox“的縮放模式,這將是固定在以後的版本。


display.screenOriginX
display.screenOriginY
Returns the x-distance and y-distance from the top-left of the reference screen to the top-left of the current screen, in reference screen units. For example, in "letterbox" or "zoomEven" scaling modes, there may be added area (or cropped area) on the current device screen. These methods let you find out how much visible area has been added or removed on the current device.
返回的x和y的距離,距離左上角參考屏幕左上角的當前屏幕,屏幕的單位參考。例如,在“letterbox“或”zoomEven“縮放模式,有可能會增加面積(或裁剪區)對當前設備的屏幕。這些方法讓你了解多少可見區域已被添加或刪除當前設備。


Dynamic Image Resolution動態圖像分辨率

Dynamic image resolution lets you automatically swap in higher-resolution versions of your images on higher-resolution devices, without having to change your layout code.
動態圖像分辨率可以自動交換在更高分辨率的版本上的圖像分辨率更高的設備,而無需改變你的佈局代碼。


The simplest example is the iPhone 4, which has a resolution of 640 x 960, or exactly twice the resolution of the iPhone 3GS, which is 320 x 480. You can use content scaling in your config.lua file to scale up your original 320 x 480 application to fill the iPhone 4's screen. This works well, but does not make full use of the higher resolution — your images will not be as crisp and detailed as they could be, given all the added pixel density available.
最簡單的例子是iPhone 4,它的分辨率為 640 × 960,或究竟兩倍的iPhone 3GS的決議,這是320 × 480。您可以使用內容縮放在config.lua文件,以擴大原來的320 × 480的應用,填補了iPhone 4的畫面。這個效果很好,但不充分利用具有更高的分辨率 - 您的圖片不會像清晰和詳細,因為他們可能是,由於所有增加像素密度。


To address this issue, Apple defined a naming convention for images. Under Apple's method, developers create double-sized versions of their base images and add an "@2" suffix to their filenames, and the double-resolution versions of the images are automatically substituted on the double-resolution iPhone 4.
為了解決這個問題,蘋果定義的命名約定的圖像。根據蘋果公司的方法,開發人員創建雙大小版本的形象和他們的基地添加一個“@ 2”後綴的文件名,和雙決議版本的圖像會自動取代對雙決議 iPhone 4。


However, while Apple's system works for the iPhone 4, which is exactly 2x the resolution of previous iPhones, a more robust system is needed to support full multi-platform development, where different device resolutions do not fall neatly into a 2:1 ratio.
不過,雖然蘋果的系統的工程,iPhone 4,而這正是以前的2倍iPhone的決議,一個更強大的系統需要支持完整的多平台開發,不同的設備分辨率不屬於成一個整齊的比例為 2:1。


Instead, Corona uses a more general method for defining alternate images, which has two advantages:
相反,Corona使用更通用的方法替代圖像定義,它有兩個優點:


Corona lets you select your own image naming patterns. The "@2" convention can be used, but so can any other naming suffixes defined by you.
Corona讓你選擇自己的形象的命名方式。在“@ 2”公約可以使用,但至今不能有任何其他的命名後綴由您定義。


Corona does not require you to know the exact resolution of the target device — which may be unknown, especially for the growing range of Android devices. Instead, you can predefine several image resolution choices, and Corona will automatically find the closest match on each device.
Corona不需要你知道確切的目標設備的決議 - 這可能是未知的,尤其是對範圍日益擴大的Andr​​oid設備。相反,你可以預先定義幾個圖像分辨率選擇,Corona會自動找到最接近的每一個設備。


To define your image naming convention, and the corresponding image resolutions, a table named imageSuffix is added to config.lua, inside the content subtable. Here is an example of a config.lua file that defines four alternative image resolutions:
要定義你的形象的命名規則,以及相應的圖像分辨率,表名為 imageSuffix添加到config.lua,裡面的內容子表。下面是一個例子一config.lua文件定義了四個替代圖像分辨率:


------------------------
application =
{
    content =
    {
        width = 320,
        height = 480,
        scale = "letterbox",
 
        imageSuffix =
        {
            ["@2"] = 2,
            ["@3"] = 3,
            ["-bar"] = 3.3,
            ["-foo"] = 4.5,
        },
    },
}
----------------------------
This is probably more complex than a real-world example would be, but it demonstrates several possibilities for image naming conventions. In this case, the file defines the "@2" suffix as referring to images with 2x the base resolution, and similarly the "@3" suffix as meaning 3x the base resolution. But any names and resolution ratios are allowed, including non-integer values, so the "-bar" suffix is defined as being 3.3x the base resolution, and the "-foo" suffix means 4.5x the base resolution.
這可能是更複雜的比真實世界的例子是,但它演示了幾種可能的圖像命名約定。在這種情況下,該文件定義了“@2“的後綴,它是指圖像分辨率和2倍的基礎,以及類似的“@3“後綴的含義3倍基決議。但是,任何名稱和分辨率比是允許的,包括非整數值,因此,“-bar“後綴被定義為3.3x決議的基礎,而“-foo“後綴是指4.5倍的基礎決議。


With the above defined, the corresponding set of images would be created as follows. Assuming a base image named myImage.png, with a size of 100 x 100 pixels, the alternate images would be:
有了上述定義,設置相應的圖像將被創建如下。假設一個名為 myImage.png基地形象,有大小100 ×100像素,圖像的替代將是:


myImage@2.png (200 x 200 pixels)
myImage@3.png (300 x 300 pixels)
myImage-bar.png (330 x 330 pixels)
myImage-foo.png (450 x 450 pixels)


With the alternative assets in place, simply use display.newImageRect() rather than display.newImage(), setting the target height and width to the dimensions of your base image:
隨著另類資產到位,只需使用display.newImageRect()而不是display.newImage(),設置目標的高度和寬度的尺寸你的基地的形象:


display.newImageRect( "myImage.png", 100, 100 )
Corona will then choose the closest matching suffix, defined as the one whose scale is equal to or smaller than the current content scale factor, and then map that image file into the given 100 x 100 area (defined in base coordinates).
Corona將選擇最匹配的後綴,定義為一個其規模等於或小於當前內容的比例因子,然後映射到給定的圖像文件100× 100區(定義在基坐標)。


Currently, the largest possible range of scaling factors between different devices is about 2.4 to 1, so the above example is somewhat exaggerated. Today's most common case will likely be double-resolution alternate images for use with iPhone 4 and iPad, rather than this set of higher values. In the future, the range of possible cases is likely to be greater, as iOS and Android devices multiply.
目前,最大的可能範圍內不同的設備之間換算係數大約為 2.4比1,因此上面的例子是有些誇大。當今最常見的情況可能會是雙圖像分辨率交替使用與 iPhone4和iPad,而比這一套更高的價值。在未來,可能案件的範圍可能會更大,因為 IOS和Android設備繁殖。


Note that you do not need to provide all (or any) of the alternate images for every case. When you use display.newImageRect(), Corona will automatically look for the best match available for the target screen, and when that image is unavailable, it will work its way down the list of lower-resolution choices, finally falling back to the base image filename if no other choice is available.
請注意,您並不需要提供全部(或任何)的替代圖像的每一個案件。當您使用display.newImageRect(),Corona會自動尋找可用的最佳匹配為目標的屏幕,而當這種形象是不可用,其工作方式將在列表中向下較低分辨率的選擇,終於回落到基圖像文件名,如果沒有其他選擇可用。


It is likely that some images in your application are more prominent or important than others, so you can selectively add higher-resolution versions in the cases where it matters most. The caveat is that the base image called in display.newImageRect() must always exist, even if none of the alternate choices do.
很可能有些圖片在你的應用較為突出或重要的不是別人,這樣你可以有選擇地添加更高分辨率的版本,它的情況下,最重要的。需要說明的是,該基地的形象稱為 display.newImageRect()必須始終存在,即使沒有做的替代選擇。


Frame rate control
By default, the frame rate is 30 fps. We now allow you to optionally set the frame rate to 60 fps by adding the fps key to config.lua:
幀速率控制
默認情況下,幀頻為 30幀。我們現在讓你選擇設置幀頻為 60 fps的幀中加入關鍵 config.lua:
------------------------
application =
{
    content =
        {
            fps = 60,
        },
}
-----------------------


Note
To avoid image tearing, the screen refresh rate in Corona is now locked to the hardware refresh rate on the iPhone, which is 60 fps. Therefore, the Corona framerate must be a number that divides evenly into 60. We are currently assuming that setting a rate below 30 fps is not a priority, which leaves two possible choices: 30 fps and 60 fps. Values other than 60 in this setting will be ignored.
注意:
為了避免圖像撕裂,屏幕刷新率鎖定在Corona是現在的硬件更新速度的iPhone,這是60幀。因此,Corona幀率必須是一個數字的鴻溝平均分為 60。目前,我們正在制定一個假設率低於30 FPS是不是一個優先事項,這讓兩種可能的選擇:30 fps和60 fps的。 60以外的值在此設置將被忽略。


Anti-aliasing
反鋸齒
Corona uses software anti-aliasing for its vector objects. Previously, this anti-aliasing was on by default. It is now off by default, which will greatly improve performance of vector objects, and should make little visual difference on the latest high-dpi devices.
Corona使用軟件的抗混疊的矢量對象。在此之前,這種反鋸齒,是在以默認。現在是默認關閉的,這將大大提高性能的矢量對象,並應使視覺差異不大的最新高DPI設備。


To turn it on again, you must create a config.lua file and add an antialias key:
要再次打開它,你必須創建一個 config.lua文件,並添加了抗混疊的關鍵:
---------------------------------
application =
{
        content =
        {
                antialias = true,
        },
}
---------------------------------
Build Configuration: build.settings


Build-time properties can be provided in an optional build.settings file, which uses Lua syntax. An example of a build.settings file:
構建時特性可以提供一個可選 build.settings文件,它使用Lua的語法。一個例子一build.settings文件:
-----------------------------
settings =
{
        orientation =
        {
                default = "portrait",
        },
 
        iphone =
        {
                plist =
                {
                        UIRequiredDeviceCapabilities = "magnetometer",
                        UIPrerenderedIcon = true,
                },
        },
 
        build =
        {
                custom = "a1234",
        }
}
---------------------------------
You can also use dot syntax instead of a Lua table constructor to define your build settings. This alternate syntax is required for some device-specific plist keys that contain special characters, like the tilde (~). The following build.settings file demonstrates how to include both dot and table constructor syntax:
您也可以使用點語法,而不是一個 Lua表的構造來定義生成設置。這種替代語法一些設備需要特定plist中包含特殊字符鍵,如波形符(〜)。下面build.settings文件演示如何包括點和表構造語法:
------------------------------
settings =
{
    orientation =
    {
        default = "portrait",
        supported =
        {
            "portrait", "portraitUpsideDown", "landscapeRight", "landscapeLeft"
        }
    },
    
    
    iphone =
    {
        plist =
        {
            UIInterfaceOrientation = "UIInterfaceOrientationLandscapeRight",
 
            UISupportedInterfaceOrientations =
            {
                "UIInterfaceOrientationLandscapeLeft",
                "UIInterfaceOrientationLandscapeRight"
            },
            
            UIApplicationExitsOnSuspend = true,
            UIStatusBarHidden = true,
            UIPrerenderedIcon = true
            
        }
    }
}
 
 
settings.iphone.plist["UIInterfaceOrientation~ipad"] = "UIInterfaceOrientationPortrait"
settings.iphone.plist["UISupportedInterfaceOrientations~ipad"] = 
{
    "UIInterfaceOrientationPortrait",
    "UIInterfaceOrientationPortraitUpsideDown"
}
------------------------------------------
The build.settings file is used to set application orientation and auto-rotation behavior, along with a variety of platform-specific build parameters.
該 build.settings文件用於設置應用程序定位和自動旋轉行為,以及各種特定於平台的構建參數。


In addition, there is a custom build parameter for creating device builds with specific test versions of Corona. Currently, the only publicly available option is the temporary Beta 3 compatibility setting (which will be deprecated in the future), but others may be announced in the future.
此外,還有一個自定義生成參數創建設備建立與特定的測試版本的Corona。目前,唯一的公開的選擇是暫時的Beta 3的兼容性設置(這將在未來被廢棄),但其他人可能在將來公佈。


Info.plist Values (iOS)


Within build.settings, the optional “plist” table, within the “iphone” table (as shown above), can be used to set values in the compiled application’s Info.plist file. This has a number of uses, such as specifying device requirements or capabilities for the App Store. In the above example, the UIRequiredDeviceCapabilities key is set to “magnetometer”, which is required for apps using the Compass API to indicate to the App Store that they require devices with a compass. Also, the UIPrenderedIcon key is set to true, which prevents the iPhoneOS from adding the “shiny” highlight to the application icon.
在build.settings,可選“plist中“表,在“iPhone“表(如上所示),可以用來設定值在編譯的應用程序的Info.plist文件。這一個數字的用途,如指定設備的需求或功能的應用程序商店。在上面的例子中,UIRequiredDeviceCapabilities項設置為“磁力“,這是應用程序所需的API來使用羅盤指示的App Store,他們需要的設備和一個指南針。此外,UIPrenderedIcon項設置為 true,這可防止iPhone操作系統從加入“閃亮“突出顯示應用程序圖標。


For boolean values in Info.plist keys, use Lua-style booleans (true and false, without quotes) rather than Objective-C style booleans (“YES” and “NO”).
對於布爾值Info.plist中鍵,使用Lua風格的布爾值(true和false,不帶引號),而不是目的,C風格的布爾值(“是”和“NO“)。


The table name “iphone” refers to the iOS platform, which also includes the iPad.
該表命名為“iPhone“是指內部監督辦公室的平台,其中也包括在IPAD。


See the Apple developer documentation for more information on supported Info.plist values and what you can do with them.
看看蘋果開發者文檔的更多信息,價值觀和支持Info.plist中你可以與他們無關。
更多資訊請看 Apple developer documentation的supported Info部分,你可以對有關plist的value如何操作


Orientation Support (iOS) 定向支援辦公室(IOS)


The build.settings file can be used to set application orientation, including auto-orientation with the accelerometer.
該 build.settings文件可以被用來設置應用方向,包括自動方向與加速度計。


On iPhone and iPad, it is important to understand that there are actually three different things that are subject to orientation:
在iPhone和iPad,重要的是要明白,其實有三個不同的東西,受的方向:


The splash screen image初始屏幕圖像


The native UI elements, such as the keyboard and alert popups
本機用戶界面元素,如鍵盤和警報彈出窗口


The Corona canvas itself畫布本身Corona


In many cases, you may want (2) and (3) to have the same orientation, but note that there are also cases in which you want to orient them separately.
在許多情況下,您可能希望(2)及(3)有相同的方向,但是請注意,也有個案要分開的方向。


For example, you might create an iPad game with no “correct” orientation, but still want the iPhoneOS notification dialogs to appear right side up from the current player’s point of view. Alternatively, you might want to lock the orientation of the Corona canvas, because you are performing your own orientation changes using Corona animation (as shown in the Fishies sample code), but you still want the native UI elements to appear in the current orientation.
例如,您可以創建一個 iPad的遊戲,沒有“正確“的方向,但仍然希望iPhone操作系統通知對話框出現右側從目前球員的觀點。或者,您可能要鎖定方向的Corona帆布,因為你是你自己的方向的變化進行使用Corona動畫(Fishies所示的示例代碼),但你仍然希望本地UI元素出現在目前的方向。


To control these various possible scenarios, there are now three optional key/value pairs within the orientation table in build.settings: default, supported, and content. The following scenarios demonstrate usage by example.
要控制這些 various可能發生的情況,現在有三個可選的鍵 /值雙,方向表build.settings:默認,支持和內容。以下方案說明用法範例。


Auto-rotation自動旋轉
To auto-rotate to all four orientations, you could use the following build.settings file:
要自動旋轉到所有四個方向,你可以使用下面的build.settings文件
--------------------------------------------------
settings =
{
        orientation =
        {
                default = "landscapeRight",
                supported =
                {
                        "landscapeLeft", "landscapeRight", "portrait", "portraitUpsideDown",
                },
        },
}
--------------------------------------------------
The default orientation setting determines the initial launch orientation on the iPhone, and also the initial orientation of the Corona simulator.
默認的方向設置確定首次推出的iPhone的方向,也是初始取向的Corona模擬器。


Note注意:
On Android, the default orientation setting has no effect. The orientation is initialized to the actual orientation of the device (unless only one orientation is specified). Also, the only supported orientations are landscapeRight and portrait. On a device, you can flip to either landscapeRight or landscapeLeft, but the OS only reports one flavor of landscape, and Corona's orientation event chooses landscapeRight.
在Android,默認的方向設置不起作用。初始化的方向與實際方向的設備(除非只有一個方向是指定)。此外,僅支持方向是landscapeRight和肖像。在設備上,您可以翻轉要么landscapeRight或landscapeLeft,但操作系統只報告一種味道的風景,和Corona的方向選擇 landscapeRight事件。


When you change the device or simulator orientation, the Corona view will auto-rotate, within the orientations supported. In addition, native UI (on the device) will auto-rotate. The auto-rotation is such that to the user, the content appears "upright". Also, the position (0,0) within Corona will correspond to the upper left-hand corner of the current screen orientation.
當您更改設備或模擬器方向,Corona視圖將自動旋轉,在方向的支持。此外,本機用戶界面(在設備)會自動旋轉。自動旋轉,這樣給用戶,內容顯示為“正氣“。此外,位置(0,0)在Corona將對應到上左角當前屏幕的方向。


Note that the iPad ignores the default setting, and attempts to launch in the current physical orientation of the device, assuming that orientation is found on the supported list. To avoid unexpected orientation display issues, it's recommended that your project's build.settings specify allowed orientations for all iPad projects.
請注意,在IPAD忽略了默認設置,並嘗試推出在當前的物理定位裝置,假設方向上找到支持列表。為了避免意外的方向顯示問題,建議該項目的build.settings指定允許的方向iPad的所有項目。


If you are writing an iPad app that supports multiple orientations, you should also provide a splash screen for each of the orientations, or the App Store reviewers may reject your app. The iPad supports the following naming conventions for orientation-specific splash screen files:
如果你正在編寫一個應用程序,支持多種 iPad的方向,你也應該提供一個啟動畫面的每個方向,或App Store的評論可能會拒絕你的應用程序。在IPAD支持以下命名約定為取向的特定啟動畫面文件:


Default-Portrait.png
Default-PortraitUpsideDown.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png


Note that the "Portrait" and "Landscape" splash screens in the list above will automatically handle two types of orientation each, unless you decide to provide more specialized files, such as "LandscapeLeft". Also, all splash screen graphics provided should be internally upright -- one common misunderstanding is that the "PortraitUpsideDown" graphic should actually be created upside down, which is incorrect.
請注意,“肖像“和“山水“撲通屏幕上述的名單將自動處理兩種類型的每個方向,除非你決定提供更專業化的文件,如“LandscapeLeft“。此外,所有閃屏圖形應提供內部直立- 一個常見的誤解是,“PortraitUpsideDown“圖形實際上應該是建立上下顛倒,這是不正確的。


Landscape orientation橫向

To support a single orientation (for example, landscape-only), build.settings should look like this:
為了支持一個方向(例如,只有景觀),build.settings應該是這樣的:
---------------------------------
settings =
{
        orientation =
        {
                default = "landscapeRight",
                supported =
                {
                        "landscapeLeft", "landscapeRight"
                },
        },
}
------------------------------------
In this sample, both of the equivalent landscape orientations are supported (landscapeRight and landscapeLeft). It has become fairly common for iPhone apps to only support one orientation, but Apple now encourages iPad developers to support all equivalent orientations: for example, a landscape app should support both landscapeLeft and landscapeRight, and a portrait app should support both portrait and portraitUpsideDown.
在此示例,這兩個方向的等效景觀支持(landscapeRight和landscapeLeft)。它已成為相當普遍的iPhone應用程序只支持一個方向,但蘋果現在鼓勵 iPad的開發者支持所有等效方向:例如,一個景觀的應用程序應該支持landscapeLeft和landscapeRight,以及應用程序應該支持肖像肖像和portraitUpsideDown。


Again, the position (0,0) within Corona will correspond to the upper left-hand corner of each screen orientation.
同樣,位置(0,0)在Corona將對應於左上方角落,每個屏幕的方向。


Orientation of native UI only只有定位本地UI


There are scenarios in which you want the native UI elements to auto-rotate, or to be oriented in a specific way, but you also want to maintain a fixed coordinate system within Corona (which matches the previous behavior in Corona SDK 1.x).
有些情況要在其中本地用戶界面元素的自動旋轉,或將要面向一個特定的方式,但你也希望保持一個固定的坐標系統內Corona(這在以前的行為相匹配的SDK1.x的Corona) 。


For example, you may have a multiplayer game where any orientation is equally valid, or you may want to manually define the animation that occurs on orientation change (e.g., animate a dissolve and/or rotation between the sideways and upright interface layouts). The only way to do this is through a fixed Corona coordinate system where you manage your own rotation behavior in Lua. Because Corona renders its graphics to an OpenGL canvas that is separate from the other native elements, it is possible to control the rotation behavior of this canvas independently.
例如,你可能有一個多人遊戲,任何方向上同樣有效,或者您可能需要手動定義動畫方向上發生變化(例如,動畫一溶解和/或旋轉之間的橫向和垂直界面佈局)。只有這樣,才能做到這一點是通過一個固定的坐標系統,其中Corona您管理自己的旋轉行為在Lua。由於Corona呈現其圖形的OpenGL畫布獨立於其他本土元素,它是可以控制這個畫布旋轉行為獨立。


To lock Corona’s orientation while allowing native iPhone UI elements to rotate, add a content parameter in build.settings:
要鎖定Corona的方向,同時允許本地iPhone UI元素進行旋轉,添加內容參數 build.settings:
-----------------------------
settings =
{
        orientation =
        {
                default = "portrait",
                content = "portrait",
                supported =
                {
                        "landscapeLeft", "landscapeRight", "portrait", "portraitUpsideDown",
                },
        },
}
------------------------------
Similarly, to lock Corona’s internal coordinate system to portrait orientation (e.g., for compatibility with your older Corona code) while locking iPhone UI elements to landscape orientation, you could do the following in build.settings:
同樣,要鎖定Corona的內部協調制度,以縱向(例如,為了兼容性與您的舊Corona代碼),而鎖定 iPhone的UI元素,橫向,你可以做以下的build.settings:
------------------------------
settings =
{
        orientation =
        {
                default ="landscapeRight",
                content = "portrait",
                supported =
                {
                        "landscapeRight",
                },
        },
}
---------------------------------
Orientation naming conventions定位命名約定


Orientations follow the UIInterfaceOrientation conventions on the iPhone (not to be confused with UIDeviceOrientation). These are defined as follows:
按照UIInterfaceOrientation公約取向上的iPhone(不要混淆UIDeviceOrientation)。這些定義如下:


*portrait - device in the upright position with the Home button on the bottom
*landscapeRight - device in the sideways position with the Home button on the right
*landscapeLeft - device in the sideways position with the Home button on the left
*portraitUpsideDown - device in the upside down position with the Home button on the top
portrait- 設備處於直立狀態的主頁按鈕在底部
landscapeRight-裝置在橫向位置的主頁按鈕在右邊
landscapeLeft-裝置在橫向位置上的主頁按鈕在左側
portraitUpsideDown-設備處於倒掛位置與Home按鈕頂部

About combining dynamic scaling and auto-rotation
關於結合的動態縮放和自動旋轉

As discussed in Dynamic Content Scaling, Corona lets you develop content for a single "virtual" screen size which is automatically scaled up (or down) on devices with different screen sizes. However, not all dynamic scaling options will work perfectly with auto-rotation of the Corona canvas. In particular, you should avoid using the zoomStretch scaling option unless you also disable auto-rotation for the Corona canvas. For more information about disabling auto-rotation of the Corona canvas, see Orientation of native UI only.
正如在動態內容縮放,讓您開發Corona內容單一的“虛擬“屏幕大小自動調整是向上(或向下)的設備上使用不同的屏幕尺寸。然而,並非所有動態縮放選項將完全與自動旋轉畫布的Corona。特別是,你應該避免使用zoomStretch縮放選項,除非您還禁用自動輪換Corona畫布。有關更多信息有關禁用自動旋轉的Corona帆布,看到取向本地UI而已。

Detecting current device orientation目前的檢測設備方向

The current device orientation can be read from system.orientation. This property will return one of six possible string values, from a set consisting of the four orientations above plus faceUp and faceDown.
目前設備的方向可以讀出system.orientation。此屬性將返回六分之一的可能的字符串值,從一組由四個方向上面加faceUp和面朝下。


To get more detailed information about the device’s specific x, y, and z angle in space, see the section on accelerometer events in the API Reference.
要獲得更詳細的信息有關該設備的特定的X,Y和Z角的空間,看到一節加速度事件的API參考。


Orientation Support (Android)定向支持(Android)


The Android platform supports two orientations: portrait and landscapeRight (defined as above). The orientations “landscapeLeft” and “portraitUpsideDown” have no effect on Android. Also, auto-rotation is not currently supported on Android.
Android平台的支持兩個方向:縱向和landscapeRight(定義如上)。在面向“landscapeLeft“和”portraitUpsideDown“沒有對 Android操作系統。此外,自動旋轉目前不支持Android上。


Here is an example of an Android-specific build.settings file (you may also combine Android and iPhone settings in the same file):
下面是一個例子,一個 Android特定build.settings文件(您可能還結合 Android和iPhone的設置在同一個文件):
--------------------------------------
settings =
{
        android =
        {
                versionCode = "3"
        },
    
        androidPermissions =
        {
                "android.permission.ACCESS_FINE_LOCATION",
                "android.permission.INTERNET"
        },
    
        orientation =
        {
                default = "landscape"
        },
}
-------------------------------------


Version Code (Android)版本代碼(Android)


The version code can be set within an optional “android” table in build.settings. See the code above for an example.
該版本的代碼可以設定在一個可選的“Android“表build.settings。見上面的代碼中的例子。


For more information, see android:versionCode on this page. Note that this version code is an internal number used to distinguish application releases for the Android Marketplace, and is different than the version given in the Corona build dialog. The latter determines the version number displayed to the end user, also known as android:versionName.
有關詳細信息,請參閱Android:versionCode在此頁。請注意這個版本的代碼是一個內部編號來區分應用程序釋放為 Android市場,並給予不同的版本相比,在電暈建立對話。後者決定了版本號顯示給最終用戶,也被稱為Android:versionName。


Application Permissions (Android)
應用程序的權限(Android)


Finally, an optional “androidPermissions” table can be used to specify permissions, using string values as given in the Android Manifest Reference. For example, ACCESS_FINE_LOCATION and INTERNET permissions are specified in the code above.
最後,一個可選的“androidPermissions“表可用於指定的權限,使用字符串值中給出了Android清單參考。例如,ACCESS_FINE_LOCATION權限和INTERNET上面的代碼中指定。


Developers should choose the permissions that match what their application requires. In particular, set the INTERNET permission for any Android application that requries network access.
開發者應該選擇什麼權限,其應用要求相匹配。特別設置 Internet權限 Android的應用程序的任何requries網絡訪問。

arrow
arrow
    全站熱搜

    createps 發表在 痞客邦 留言(0) 人氣()