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

Time for action – adding the build.settings file

The build-time properties can be provided in an optional build.settings file, which uses the Lua syntax. The build.settings file is used to set the application orientation and autorotation behavior along with a variety of platform-specific build parameters. To add the build.settings file in your project folder, perform the following steps:

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

What just happened?

The default orientation setting determines the initial launch orientation on the device and 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 that support 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 isn't set before launching the application, it will go to the default portrait mode.

Dynamic scaling

Corona can target builds made for multiple devices across iOS and Android, which display various art assets in different resolutions. Corona can scale upward or downward depending on your starting resolution. It can also substitute higher-resolution image files when needed, ensuring that your app appears clear and sharp on all devices.