Moai tutorial series: The adventures of an intrepid programmer in the lands of Moai

This tutorial series will be a progressive journey through the Moai SDK.  To a certain degree, each is a “micro” tutorial, covering a different aspect of Moai_thumb[3]Moai.  Each tutorial builds on the last and when taken as a whole, once completed, you should have all of the information you need to successfully make a game in Moai.

This series doesn’t go into any detail about learning Lua, you will have to get that information elsewhere.

The primary goal of this series is to make learning Moai accessible to the masses and hopefully somewhat entertaining.  This is aimed at someone with prior programming experience but is by no means aimed at experts.  You should have Moai installed and configured, if you need a bit of help in this regard, check this post about getting installed and running, then check out this post about getting a Moai development environment up and running ( Intellij IDEA ), making life so much easier on our intrepid programmer.

Without further ado, let the journey begin!


The Journey…

Part 1: Opening a window and creating a viewport

In which our intrepid programmer encounters nothing, finds it rather boring, and decides to do something about it.  By “something” that creates a basic application and open a window… full of nothing, pink nothing. Pink is the new black.

pink window

Topics covered: MOAISim, MOAIEnvironment, MOAILayer2D, MOAIViewport, MOAIGfxDevice, Creating a window, creating a viewport, setting the fill color, reading from the environment


Part 2: Loading and displaying a sprite

Our brave programmer did bask for a time in the glorious pinkness, then as is the want of things, he grew bored.  So he summoned forth ap2 sprite from the nether-realms.  A sprite that looked nothing like the logo from the Watchman, just in case you happen to by a copyright lawyer that is.

Topics covered: MOAIGfxQuad2D, MOAIImage, MOAITextureImage, loading and displaying a sprite, props and decks explained


Part 3: Touching and clicking, clicking and touching

After brazenly flouting copyright law, with a new found taste for larceny our intrepid programmer decides to take a walk on the wild side, 3touching and clicking with wild abandon.  Amazingly enough, our hero is still at large and much more knowledgeable about how to touch and click things.

Topics covered: MOAIInputMgr, MOAITouchSensor, MOAIPointerSensor, handling touch and click events


Part 4: Dealing with the keyboard… or not

Flush with new found power, our intrepid programmer sets out to master the keyboard, and encounters his first small setback.  No worries, imageour intrepid programmer wouldn’t be very intrepid if he gave up in the face of a bit of diversity, would he?  Oh, he also covers displaying text on screen.

Topics covered: MOAIKeyboardIOS, MOAIInputMgr, MOAITextBox, handling keyboard support, drawing text on screen.


Part 5: Mi GUI es tu GUI… or how to make buttons and stuff

As is inevitably the case, our intrepid programmer finds himself in need of a button and a few scroll bars, looks around, and finds none.  A panic attack nearly sets in as our programmer friend begins to fear a large amount of work in his near future.  Luckily, he finds a solution in the form ofimage moaigui, a UI library for Moai.  Thanking the gods he doesn’t have to do any actual work, the programmer sets about creating some shiny buttons and stuff.

Topics covered: Configuring and using moaigui.  Creating button, label and progress bar controls.


Part 6: Who put the bomp in the Moai, Moai, Moai. Playing audio in… you guessed it… Moai

Our intrepid programmer is about to learn the ins and outs of playing audio in Moai by making a simple music player application.  At the same time, our not so intrepid author is trying his hardest to not make the far to predictable “Can you hear me know” pun!  We also use a few moreimage moaigui controls, create a coroutine, and don’t make a single AT&T pun.

Topics covered: MOAIUntzSystem, MOAIUntzSound, playing audio with Moai, handling a checkbox and slider control.


Part 7: Tile maps so easy your mother could do it

Sometimes our intrepid programmer is shocked to find out how hard some things are.  Things you expect to be easy that turn out to be anything but.  The opposite though is so rarely true, where you set out to do something hard and go “WOW, that was easy!”.  This is one such time; when our protagonist sets about creating a tilemap and succeeds with almost no effort at all!image

Topics covered: MOAIGrid, MOAITileDeck2D, supporting different resolutions, creating and displaying a tile map


Guides and other stuff to help you on your journey

This is other information I have compiled that will help you working with Moai, but doesn’t really fit otherwise:

Configuring IntelliJ IDE to work with Moai ( auto completion and run from IDE )

This guide walks through setting up the freely available IDE IntelliJ IDEA to work with Moai, this includes full code auto completion and the ability to run your code from directly within the IDE.

Building your Moai app for Android

Eventually you are probably going to want to build your application for Android.  If you have no prior Android experience, let me just say, the process is kind a pain in the ass…  it’s annoying.  You need to install a number of applications, set a number of environment variables before you can get anywhere.  Fortunately, you only have to do it once and this trusty guide will walk you through this particular minefield.

Using Moai with Chrome Native Client

Moai is also able to target Google Chrome’s Native Client, which is a fancy way of saying C++ application in the browser.  You build a compatible host, copy your lua project to that directory, do a bit of configuration and voila, you’ve got an app running full speed and in the browser.

Moai and Lua learning and reference list

This is a list of available books and key websites for learning Lua and developing with Moai.  I will keep adding to it as I discover new resources, books, and sites.

Moai configuration and of course… Hello World!

This is a simple setup/installation guide, as well as a simple Hello World.  I of course am required by law to submit a Hello World application, so here mine is.  I am many things, but a criminal is not one of them!

Scroll to Top