Game Development Reference
In-Depth Information
To add a framework to our extensions, we must edit the Gyroscope.mkf file. Look
for the deployments section for iOS towards the bottom of the file (Marmalade refers
to it as the "iphone platform" for legacy reasons) and add the following line to it:
iphone-link-opts="-framework CoreMotion"
Building an iOS extension
So far, all of the previous steps for creating an iOS extension can be done equally
well on Windows or Mac, but this final step absolutely requires us to use a Mac.
We need to ensure the Mac has access to the entire Gyroscope
directory. How you achieve this is up to you, but a good way
is to share the Gyroscope directory out on your development
Windows PC and then access this share on the Mac. This way
the code is built on the Mac but all the compiled files are already
in the correct place on your Windows development machine.
To build the extension you first need to open a Mac terminal window. Make the
Gyroscope directory the current directory in the terminal window and then enter
the following command line:
mkb Gyroscope_iphone.mkb -arm
This will build the extension and our work on the Mac is done. Simple, but kind of
annoying that we only needed to execute one command, isn't it?
Using the Gyroscope extension
We've now seen how to create and build extension modules for Windows, Android,
and iOS, but how do we make use of them in our Marmalade projects?
It's actually surprisingly easy. All we have to do is reference our extension in the
project MKB file's subprojects section (the easiest way to do this is to provide
a relative path to the Gyroscope directory from the main project directory), just
as we would with any normal code module, and then include the auto-generated
Gyroscope.h header file so we can call the extension functions.
The only thing to bear in mind is that because an extension may not have been
created for every platform we wish to target, we must make sure the extension is
available for use before we call any of its functions. This is easily done by using the
GyroscopeAvailable function that is automatically generated for us by the EDK
build scripts. If this function returns S3E_TRUE , the extension is available for use.
If it returns S3E_FALSE , any call to an extension function will fire an assert but will
otherwise do nothing.
 
Search WWH ::




Custom Search