Touch the Cat – my first mobile game!
Eee~ I’m so happy. I finally finished my first mobile game. It’s called Touch the Cat, available on Android. It’s very simple – literally: “Do this. OK, you’re done.” – but I am excited because after weeks of procrastination and perseverance, it’s finally finished and in the Play Store. :)
Written in Lua using the MOAI SDK.
Stuff I learned building this game
- To get Lua working, you need a C compiler and the Lua files. On Windows, you’ll need to get both. A Mac has the C stuff already, so just get the Lua files and do a make, then make sure the lua executable is somewhere that executes. Mine’s in my /usr/local/bin.
- The MOAI executables live in moai-sdk/bin/ – pick the one that suits the OS you’re working on and make sure it’s somewhere that executes. I can’t remember which tutorial I followed to set my environment up, but this one sounds about right.
- MOAI doesn’t have extensive official documentation, even on the wiki. Most learning happens on forums and from example. When you unpack everything, browse the moai-sdk/samples/ folder to see how things are done.
- How to work with mouse click and touch events.
- Pickle is quite good for making tiny things, which you can then edit properly in Photoshop. The client doesn’t resize yet or let you zoom, so it’s not very effective for editing images bigger than 48×48. The ‘erase with right-click’ makes editing go quickly.
- When you turn your Lua/MOAI game into an Android game, you need to download the Android SDK and NDK separately. There’s not an all-in-one package that sorts everything out for you and it’s not straightforward what you have to do. Download, unpack and install (clearer instructions for Mac, takes bloody ages).
- There are 2 phases to building a MOAI app into an Android app. The first is creating an Android host, a wrapper project that contains your real Lua/MOAI project. The second phase is shoving your Lua/MOAI project into the wrapper project. This tutorial is pretty useful, but it’s for Windows; not much different on a Mac, just substitute win stuff for mac stuff.
- If you are on a Mac, don’t use the emulator. DON’T USE THE EMULATOR. IT IS A PIECE OF SHIT. Plug in your actual device and set it to debug mode (under Settings > Developer Options).
- How to build a Hello World Android app – just to test that your setup and env are OK before throwing MOAI into the mix.
- Your app will appear on your Android in landscape by default. Here’s how to change it. (It’s in your host-source’s AndroidManifest.xml and src/<package_path>/MoaiView.java.)
- How to get an app to fit the screen size of your mobile device.
- The final hoops to jump through to build and prepare your .apk for going on the store.
Huge thank you to Doug, Brendan, Niaal, Corv and Kai for their help with this. Very much would not have been possible without their support, encouragement and explaining of stuff with simple words. ^___^