In our Display Objects
project, we left off displaying a background image and three similar display objects in the simulator. When running the project on different devices, the coordinates and resolution size were most compatible with the iPhone only. When building applications for multiple devices across iOS and Android platforms, we can configure it using a config.lua
file that is compiled into the project and accessed at runtime. So let's get to it!
application = { content = { width = 320, height = 480, scale = "letterbox", xAlign = "left", yAlign = "top" }, }
config.lua
in your Display Objects
project folder.You have now learned a way to implement an easy configuration to display your content across a variety of devices on iOS and Android. Content scaling features are useful for multiscreen development. If you look in the config.lua
file we created, width = 320
and height = 480
. This is the resolution size that the content is originally authored for. In this case, it is the iPhone 3G. Since we used scale = "letterbox"
, it enabled the content to uniformly scale up as much as possible while still showing the entire content on the screen.
We also set xAlign = "left"
and yAlign = "top"
. This fills in the empty black screen space that shows on the Droid specifically. The content scaling is at the center by default, so aligning the content to the left and top of the screen will take away the additional screen space.