Corona SDK Mobile Game Development:Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – adding build.settings file

Build-time properties can be provided in an optional build.settings file, which uses Lua syntax. The build.settings file is used to set application orientation and auto-rotation behavior, along with a variety of platform-specific build parameters.

  1. Create a new project folder on your desktop called Breakout.
  2. In your preferred text editor, make a new file called build.settings and save it to your project folder.
  3. Type in the following lines:
    settings =
    {
      orientation =
       {
        default = "landscapeRight",
       }
    }
  4. Save and close. The build.settings file is completed.

What just happened?

The default orientation setting determines the initial launch orientation on the device, and also the initial orientation of the Corona simulator.

The default orientation doesn't affect Android devices. 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 operating system only reports one flavor of landscape, and Corona's orientation event chooses landscapeRight.

We have created this application to work with landscape orientations, supporting landscapeRight. We have set this orientation as its default so it won't switch to landscapeLeft or even any portrait mode. While working on an iOS device, if the build.settings aren't set before launching the application, it will go to the default portrait mode.

Runtime configuration

Currently our project is not scaled to display evenly for cross-platform development. The contents will still display on the device, but most likely not in the correct aspect ratio.

For example, iPhone projects are designed for a 320 pixel wide screen and can be up scaled to the 480 pixel wide screen for Android devices. This makes porting easier, since the code and art assets do not need to be revised.

Corona can target builds made for iPhone 4 and other current iOS devices that display double resolution art assets while remaining iOS 3.0-compatible. This means that pre-iPhone 4 content will no longer upscale automatically to the larger iPhone 4 screen resolution. As iOS development progresses, content scaling will generally be required in new iPhone apps to be compatible with devices such as the iPhone 3GS and lower.