How do I Develop Cross-Platform in LiveCode?
This lesson discusses the cross-platform development capabilities of LiveCode and provides screen captures of one of our in house games that we developed in 3 hours and 16 minutes. The game is now available from the Apple store.
A link to the source code and screen captures of the game on multiple platforms are provided.
With the introduction of new technologies, new computer platforms and changes in consumer electronics trends arise increasing challenges for developers who aim to deploy their products to multiple systems in which they see a target audience.
New or different technologies usually require applications to be partially or completely rewritten so that they can be deployed to another platform. This is often an expensive process both in development effort and time it may take to get to know a new technology, not to mention the need to maintain and upgrade multiple implementation instances of a single application concept.
LiveCode addresses the cross-platform deployment problem by allowing a developer to write software once and deploy it to a number of different platforms. This does not only target a particular hardware architecture but also software environments that may run on a particular platform. For example, LiveCode allows you to deploy to iOS devices, Android devices, Apple Mac, Server, or even Linux, Windows and Web which may all be running on an Intel PC. This wide variety of platform support from a singe code base can increase cross-platform development significantly, allowing existing LiveCode applications to be moved to new environments in a very short time.
As LiveCode supported consumer devices now span desktops, servers, mobile phones and tablets, it is important to keep in mind that each of these device families has unique control and display properties that may not be shared with every device on which LiveCode can be deployed.
The Sheep Herder is a very simple game we developed in 3 hours and 16 minutes. This game was used to test our early iOS support and demonstrate the possible time it may take to develop an application with our development environment. The game has since been released to the Apple store and the source can also be downloaded from revOnline.
The aim of the game is to move as many sheep in a set time frame into a teleporter. The more sheep you teleport, the more points you get.
What does Cross-Platform mean in LiveCode?
You can set up LiveCode to deploy to other platforms by using the Standalone Application Settings. This allows you to specify the platforms you would like to deploy to and define settings that may be specific to the platforms you are intending to support.
Once you have selected the deployment options, you can save the target specific builds to your file system. The Android pre-release uses a plugin for building and testing. You can find out how to use the Android plugin here: The Basics: How do I Create Hello World on Android?.
The Sheep Herder was developed for iOS, using some game controls that are very specific to iOS and are not available on some of the other platforms that LiveCode supports. In particular, Sheep Herder supports the shake motion that is not available on desktop machines and multi-touch that is available on only a few mobile devices. This does not mean that Sheep Herder will not run on other platforms, such as a PC or a Mac. In fact, it is possible to take the code we developed for iOS and build it for PC and Mac without any modification. You can even load and start the game, but due to the lack of shake and multi-touch support on the PC and Mac, it is not possible to play the game.
Now what does this mean to an application developer? It means that cross-platfrom development is not so much limited by the LiveCode environment, but more by the features that are supported on the device families on which LiveCode can be deployed. So if the Sheep Herder was to be deployed to a PC or Mac, the core application is already ready to run. What is missing, are iOS device specific controls that have to be replaced by controls that are native to a desktop environment. These controls can be added in only a very small number of lines of code.
Platform Deployment Examples
The figure in this step shows you what the Sheep Herder application looks like on a number of target environments. These examples use one and the same code base. From left to right, then from top to bottom, the platforms are: Windows, Mac, Linux, iPhone, Android, iPad and Web.