Resolving Black Bars on iPhone 6+/5s Screens with AS3 Starling Framework

Understanding and Resolving Black Bars on iPhone 6+/5s Screen in AS3 Starling Framework

Introduction

The AS3 Starling framework is a powerful tool for creating high-performance, cross-platform games and applications. However, when deploying these projects to iOS devices, one common issue arises: black bars at the top and bottom of the screen. In this article, we will delve into the causes of this problem, explore potential solutions, and provide guidance on how to remove black bars on iPhone 6+/5s screens in AS3 Starling.

Understanding iPhone Screen Resolutions

Before we dive into the solution, it’s essential to understand the different screen resolutions supported by iOS devices. The iPhone 6+ and 5s have the following screen resolutions:

  • Retina HD (Default): 640x1136
  • Retina HD (2x): 750x1334
  • Retina HD (3x): 1242x2208

When an iOS app is launched on a device, it will attempt to fit the app’s content into these resolutions. If the content doesn’t match the resolution, black bars will appear at the top and bottom of the screen.

Starling Framework and Screen Resolutions

In AS3 Starling, you can configure the stage to use a specific resolution by setting the stageWidth and stageHeight properties. However, this approach has limitations. When using a fixed resolution, the app will not adapt to different screen sizes or resolutions on other devices.

To resolve black bars, it’s crucial to understand that Starling does not natively support multiple screen resolutions out-of-the-box. Therefore, we must employ workarounds to handle these situations effectively.

Launch Images and Resolution Adaptation

One of the most effective solutions is to use a launch image for your iOS app. This image serves as a starting point for the app’s content when it is launched on an iPhone 6+/5s device. By providing a launch image that matches one of the supported resolutions, you can avoid black bars.

Here are some key points about launch images:

  • Name: The name of the launch image file should be in the format <name>@<resolution> (e.g., Default-667h@2x.png).
  • Size:
    • Retina HD (Default): 640 x 1136
    • Retina HD (2x): 750 x 1334
    • Retina HD (3x): 1242 x 2208
  • Image format: PNG, JPEG, or GIF.

To use a launch image in Starling, you can follow these steps:

  1. Create the launch image file according to your chosen resolution.
  2. Add the following code to your CHouseApp class:

var screenWidth: int = stage.fullScreenWidth; var screenHeight: int = stage.fullScreenHeight;

if (screenWidth > 640 && screenHeight > 1136) { _starling.stage.image = “Default-667h@2x.png”; } else if (screenWidth > 750 && screenHeight > 1334) { _starling.stage.image = “Default-667h@2x.png”; } else if (screenWidth > 1242 && screenHeight > 2208) { _starling.stage.image = “Default-736h@3x.png”; }


## Additional Considerations

While using a launch image is an effective solution, keep in mind the following:

*   The launch image should be in PNG format.
*   The file size of the launch image should not exceed 2MB.
*   If your app requires multiple resolutions or aspect ratios, consider adding more launch images.

## Conclusion

In this article, we've discussed how to remove black bars on iPhone 6+/5s screens when using AS3 Starling. By understanding the different screen resolutions supported by iOS devices and employing workarounds such as launch images, you can effectively resolve this common issue in your applications.

Last modified on 2024-02-19