Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
27. January 2013


LibGDX is a popular Java based open source cross platform game programming library that supports desktop, Android, HTML5 and now… iOS.


Other details about this release:


  • Minor changes to the Livewallpaper API. Note that the LWP support is still a little buggy. It’s a contribution, and while i did quite a bit of clean-up it’s still not entirely where it should be. I’d be super happy if someone took on that backend!
  • If you want to deploy to HTML5 you now need to use GWT 2.5!
  • We have rudimentary Maven support. Thanks a ton to Team Gemserk for libgdx mavenizer and all their help with this!.
  • Android Daydream support, a contribution by talklittle! This one is stable.
  • Gdx controllers extension, for Android/Ouya and desktop. HTML5 could be an option too! Volunteers? (looking at you Nex) Some notes on the current stub backend for HTML5
  • The gdx-net API is now part of core. Fetching things via HTTP should work on all backends. Here’s a little test. Big thanks to Noblemaster and Gemserk who led this effort!
  • Not exactly part of the release, but here’s a quick rundown on how to make your libgdx game work with Ouya!
  • Again, not exactly part of the release, but here’s an awesome guide by Swarm on how to integrate Swarm with your libgdx app! Note that you should probably interface the Swarm API so your desktop project continues to work.
  • First release of the iOS backend



The iOS release does have some caveats though.  You need a Mac, XCode and ( here’s the stickler ) a MonoTouch license, just like the PlayN project’s iOS port.  Unfortunately, MonoTouch costs 400$, so this is one of those things you should be aware of upfront.


That said, iOS is often the biggest market place, so being able to port your game could be easily worth the 400$ price tag. 


The following features are in the queue for the 0.9.9 release:



You can read the entire release notes here, and access the source code here.


Nice work LIBGDX team.


28. August 2012


This guide will run through the process of creating and building an Android host for use with Moai.


There are a number of installs and configurations you need to perform before you can build Moai for Android.  If you need details on any of the individual steps, click the link to jump to more details on that part of the process.  If you think it seems like quite a list… you are right, it is!  Fortunately you only have to do it once!


In order to build the Android host you need to:


Install and configure all of those items before continuing these instructions.  Seriously, you need everything above, so install and perform every configuration step or the following is guaranteed to fail!



Creating an Android Host


Open a cygwin terminal

Change directory to where you want to install the Moai source code.  I am going to install to C:\, which under cygwin is /cygdrive/c, so:

cd /cygdrive/c

Now run git to download the newest Moai source code, enter:

git clone git://

Let git run, it will download and clone the most recent source code to the folder c:\moai-dev.  Make a cup of coffee, it might take a few minutes.



Now we want to build our Android host, to do so, change into the folder c:\moai-dev\ant\ and run the script  You pass in the name of the  package you want created in Java form ( reverse url, com.yourdomain.yourappname ) like so:

cd /cygdrive/c/moai-dev/ant

./ –p com.gamefromscratch.moai

It should run and complete without issue.  Should being the operative word, in my case I was actually getting a permission denied error on one the library files.  A quick chmod 644 permission setting on the file fixed that issue.  Once the script completes, it will have created a directory in the /ant folder called untitled-host.



In untitled-host, locate and edit the file, locate the the line android_sdk_root and edit it to match the path to your android sdk ( note, SDK not NDK! ), mine looks like:


Then scroll down to the section src_dirs and set it to the directory containing your Lua project, such as:

src_dirs=( "cygdrive/c/luasource" )

Save your changes and exit.


Now optionally edit  Most importantly, locate the line:

requires=( "miscellaneous" "adcolony" "google-billing" "chartboost" "crittercism" "facebook" "google-push" "tapjoy" )

and change it to just:

requires=( "miscellaneous"  )


Unless you specifically need to include those libraries.  Tapjoy and Facebook are currently broken though, so if you include them, you will have trouble later!  You can optionally set your app name, version number, icon names, etc at this point. (Actually, this part seems to be ignored anyways…)

Save and exit.


Not type ( in the untitled-host folder ) :



So long as you didn’t get any errors, your project should now have been created. 


Loading and running the generated project in Eclipse


Fire up Eclipse.

Select the menu File->Import…

Select General->Existing Project into Workspace, like so:



Click Next.


Check Select root directory and navigate to c:\moai-dev\ant\untitled-host\build\project like so:



Click Finish.


As you can see, even though you said you didn’t want them, Facebook and Tapjoy are still included, and are still broken.




Right click and choose Delete for each one.


Once those are removed ( or you can optionally find and fix the external libraries they depend on instead of removing them. ), your application should build just fine.  Make sure your Android device is plugged in and has debugging enabled ( in the settings on the device ).  Right click your project, select Run As… Android Application



A few seconds later, your application should appear on your device.


The actual lua code for your application will be located in the lua folder within the assets folder.




Happy Androiding!



If these instructions don’t work for you, do not be surprised.


1- Moai is under active development

2- The whole Java build system is horrifically complex and exceedingly fragile

3- Eclipse is the devil




Installing Cygwin


Cygwin is a unix like environment for windows and is critical to successfully building the Android hosts with Moai.  First thing download setup.exe from here (direct link to exe).  Your browser may fight you a bit about downloading an executable directly.


Once downloaded, run setup.exe, saying yes to any security prompts.


Select Download from Internet.


Click Next.


Pick whatever directory you want to install to, I kept the default of c:\Cygwin. 


Click Next.


Next you need to pick the directory to download to, again I just went with the defaults:


Click Next.


Defaults again unless there is something odd about your internet connection:


Click Next.


Select the download location that is closest to you, then click Next:




The downloader will run for a few seconds.  You may get a prompt saying this is the first time you have installed Cygwin and be sure to check the documentation.  Simply click OK.  At this point, you will get a window asking you to select the packages to install, like so:




Install the devel selection of tools, simply click the icon beside the Devel tree and it will switch from Default to Install, like this:


NOTE: *** You don’t actually need the entire Devel tree and this process will take a really long time to complete ( two hours on my laptop ) if you select the full Devel tree.  However, selecting all developer tools guarantees that you get everything required as part of the build process.  You can experiment with selecting individual packages if you wish.


Click Next.


You will most likely get a prompt about resolving dependencies, like so:



This is normal, click Next.



Setup will now download all of the packages you have selected:





This process is not… short.  Have patience, lots of patience.  Have you considered picking up a new hobby?  Knitting perhaps?  Go for it!  You have plenty of time.


Cygwin installation is now complete.





You can always run setup.exe again if you want to enable or remove features in the future.


Cygwin is now configured.


Installing the Android NDK


Head over to the Android NDK page and download the appropriate file. I went with, but this will obviously change in version name over time.


Once downloaded, open the archive and extract the folder inside to somewhere on your drive.  In my case the folder was called android-ndk-r8b and I extracted it to c:\.  After it is extracted, rename it to android-ndk.  There are 17,000+ files in that archive, so expect it to take a while to extract.


Later in the process, Moai will need to know the location of the NDK, specifically ndk-build.  The easiest way to make this file discoverable is to add it to your path environment variable, this can be configured via the command line:


setx PATH ‘%PATH;c:\android-ndk’.


The NDK is now installed.



Installing the Java JDK and set the JAVA_HOME environment variable


You need to have a Java JDK installed and configured.


Download the JDK from this website.  Chose whichever version you want, it shouldn’t matter.  There are some annoyances with using Android tools with Java 7 ( 1.7 ), so Java 6 may be the best choice for now.


Once downloaded and installed, be sure that JAVA_HOME is set to your install directory.  Mine for example is c:\Program Files\Java\jdk1.7.0_03


Once again, you can set this environment variable from the command line using the setx command.




Installing Apache Ant


Go here to the Apache Ant download page and download the zip file.  I selected

Open the archive and extract the folder (apache-ant-1.8.4 in this case ) to a location on your drive.  I went with c:\ again.


Set the environment variable ANT_HOME and point it to this directory ( c:\apache-ant-1.8.4 in my case), you can do this from the command prompt with the command:

setx ANT_HOME c:\apache-ant-1.8.4

Like so:



Ant is now configured.



Installing the Android SDK, Eclipse and the Android Plugins


You can download the Android SDK here, which full instructions here.  Be sure to install at least the Android 2.2 ( Platform 10 ) platform as described here.


The first half of this guide covers the installation process for installing Eclipse.  You need to install Eclipse as well as the Google ADT to complete this process. Eclipse 3.7 or 3.8 will work, although might require a minor change during the install process.


17. July 2012


Google’s cross platform PlayN game library has just released version 1.4.  PlayN enables you to target desktop, iOS, Android, HTML5 and Flash using a single Java code base.



Details of this release:



PlayN 1.4 highlights:

- You can now find out when your Android or iOS game is paused and
resumed via PlayN.LifecycleListener.

- WebSocket support has been added (only works on HTML and Java
backends right now).

- Custom GLSL shaders are now supported on all GL-based backends
(HTML5/WebGL, iOS, Android, Java).

- You can use JavaPlatform for your unit tests without having to wire
up the LWJGL native libraries: use JavaPlatform.registerHeadless.

TriplePlay 1.4 highlights:

- Page turn and (iOS-style) flip transitions that use custom shaders
to achieve real 3D perspective (check out the demo on a WebGL-capable

- The long awaited particle system has arrived, break out the
fireworks. This currently only works on GL-based backends, but may
some day work on non-GL backends (less performantly).

- There are a couple of not-yet-finished cool new things:

  • a mechanism for syncing persistent storage across multiple clients
    with conflict resolution (so people can play your games on all their
    devices with the same save game state)
  • a player for our Flash animation exporter
    (, so you can export animations
    from the Flash authoring tool and use them in PlayN games


Full release notes available here.


I have created a number of getting started guides for PlayN, start here for Eclipse and right here for Netbeans.  Of course, be sure to update the version number in either guide.  Once you get through the install process, it’s a very nice library to work with.


27. May 2012


Quickly following on the release of PlayN 1.3, a new release Playn 1.3.1 has been announced.  There aren’t a lot of changes, mostly just cleaning up the maven integration.  It has absolutely no effect on the NetBeans instructions I posted earlier.  If you are working on an iOS project, I am sure you will appreciate the updated instructions though!


Hot on the heels of the 1.3 release, I present the 1.3.1 release! This
patch release contains a few bug fixes, a revamping of the way PlayN
Game projects are organized with Maven, and instructions on how to
build for iOS (made possible by simplifications to the build process
that I got into this patch release)


Full release notes available here.


24. May 2012


This tutorial is going to cover everything you need to know to get a PlayN project up and running using NetBeans.  In the end you will know everything you need in order to be able to create and run the Java, Web and Android projects using PlayN 1.3.  The iOS project should work as well, but I am not on a Mac.


I have come to a conclusion recently.  I hate Eclipse, every time I work in it, I am fighting with the IDE more than anything else.  More specifically, I hate the M2E maven plugin more than words can describe.  I have attempted to create a series of beginner tutorials for PlayN and each and every time, I end up jumping through a half hour or more of hoops in order to get Eclipse to build my project.  Not much point in making tutorials, if my readers can’t even get PlayN up and running, right?  I don’t want to spend all of my time troubleshooting PlayN installs!  It seems like 90% of the support issues you see with PlayN revolve around Eclipse and M2E problems.


So that is what this guide addresses.  It is about getting a specific version of PlayN ( 1.3 ) running with a specific version of NetBeans ( 7.1.2 ), to the point you can run all of the different kinds of targets it supports.  So if you want to get started with PlayN development, start here!  It’s going to look long and daunting, but it really isn’t all that bad, I just go into a lot of detail.  If you’ve already got Netbeans up and running, you can skip 80% of it!



What you need to get started



Before we go too far ahead, you are going to need to have downloaded and installed a Java JDK.  Note, the JRE and JDK are different things, and you very much need a JDK installed.  I recommend version 6 over 7 ( that link was to 6 ) at this point, but either *should* work. Additionally, if you are intending to do Android development, you will have to download and configure the Android SDK.  Details on configuring the Android SDK are available here, just ignore all the Eclipse bits.


You are now going to need a version of Netbeans.  Here you have a couple of choices:




You want either JavaSE or Jave EE.  If you don’t care about HTML development, go with Java SE, otherwise go with EE.  In this tutorial we are going to go with the Java SE version and add the bits as we need them.  Download and install whichever version you choose now.  Before you install, make sure you have a Java JDK installed already, you will be asked for the JDK path as part of the install process.  Otherwise it’s just a next , I agree, next, I agree, click fest.  Unless of course you are the type that reads EULAs… in which case, see you in a couple hours!



Configuring NetBeans’ required plugins



Now that you’ve installed Netbeans, fire it up.  We need to configure a couple plugins right away.  Select Tools->Plugins




In the resulting dialog, select the Available Plugins tab, scroll down and check “Java Web Applications” then click Install.  You can skip this part if you installed Netbeans EE.




Dialog will appear, click Next




Agree to the license agreements and click Install





This process will take a few minutes, then request that it restart NetBeans, let it.


Now we need to set up the NBAndroid plugin, which is the Netbeans Android connector.  Once again select Tools->Plugins.  This time select Settings in the resulting dialog:




Then click add, and fill in the following in the dialog.  For name enter whatever you want, I went with NBAndroid.  For URL enter, now click OK.




At this point Android should show up as an option under Available plugins.  For me, as is the way with software, I encountered a bug and it didn’t.  At this point I exited and re-launch NetBeans, go to Tools->Plugins and now the options are there under Available Plugins.  If they don’t show up for you, restart Netbeans.  Now select Android and Android Test Runner for Net Beans 7.x, like so:




Click install, then as before, agree to the EULA and continue. You may run into this scary message, just click continue:





All right, Android is now configured, let’s create our project!



Creating your PlayN project



Select the File->New Project menu




In the resulting dialog, select the Maven category, then under Projects select “Project from Archetype”. Click Next.





In the next screen, on the right hand side click the Add… button





Fill the next dialog in with the following details; Group Id = com.googlecode.playn Artifact Id= playn-archetype Version 1.3, then click OK.




Now make sure your newly added Archetype is selected and click Next.





Now fill in the following details.  Name your project in ProjectName, I am going with playndemo and assume you did too for the rest of this tutorial.  Artifact Id will be set automatically.  Group id is your url, in my case com.gamefromscratch.  Be sure to specify 1.3, it will start as 1.0-SNAPSHOT, you don’t want this!  Finally, and this part is extremely important, fill in the value for JavaGameClassName!  I went with playndemo, but it is extremely important to click somewhere on the screen after setting it, another text box for example, or the setting will not be saved!!!  If you get an error later on that JavaGameClassName was not set, you ran into the bug of this value not saving. Now click Finish.





If all went well, it should have generated your project like this:





Building your project ( resolve Maven dependencies )



This next part is incredibly important, we need Maven to bring in all the various dependencies.  Right click the Meta Project and select Clean and Build.




Maven is now going to download and configure all of the various dependencies, and there are a lot of them.  Like tea?  Perhaps now would be a good time to brew a cup.  Just keep an eye on the bottom right of your screen:





Ideally what you want to see is this:




Fortunately, you only need to do that part once.  If you are sitting there thinking… wow, this really took a long time, I wonder if something went wrong?!?!?!  Nope, nothing went wrong, it really does take that long!  Welcome to maven.


Running the Desktop Java app


Normally all you would have to do is right click the Java project and choose run.  However as of right now there is a dependency on the LWJGL native dlls that you need to resolve manually. If you are reading this at some point in the future, you may no longer need to perform this step!


Try running the Java App.  Right click playndemo Java and select Run




In the resulting dialog, select your main class if required and click Select Main Class.




You will receive:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (default-cli) on project playndemo-java: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]


If you scroll up the error, you will see:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
    at java.lang.ClassLoader.loadLibrary(
    at java.lang.Runtime.loadLibrary0(
    at java.lang.System.loadLibrary(
    at org.lwjgl.Sys$
    at Method)
    at org.lwjgl.Sys.doLoadLibrary(
    at org.lwjgl.Sys.loadLibrary(
    at org.lwjgl.Sys.<clinit>(
    at org.lwjgl.opengl.Display.<clinit>(


This is because of the missing libraries, lets add those now.  ( Or if you didn’t, this problem is fixed and skip ahead! )


Head on over to LWJGL’s download site and download the binaries zip.  Now extract the contents of this file somewhere, it doesn’t really matter where.  I extracted to c:\temp, preserving folder names.  The end results looked like this:




It’s really only the native folder we care about.  Stick it anywhere, just remember the path.


Now back in NetBeans, right click playndemo Java and select Properties.





We now have to add a VM param to the Run options.  On the categories side, select Run, then on the right in VM options, add  -Djava.library.path=c:\path\to\lwjgwl\windows, like this:




Click OK, then right click the Java project and select Run.




Voila, your running Java PlayN application.  Now on the the HTML project.


Running the PlayN HTML application


Right click playndemo HTML and choose Run:




If Run isn’t an option, something went wrong when you configured the Java Webserver plugin, or you aren’t running EE edition.  Go back and repeat that step until run appears.


On first run ( assuming you didn’t install a webserver as part of your Netbeans install ), you will encounter this dialog with an empty server list:





We now need to install and configure a web server, don’t worry, its an easy process.  In the menu, select Tools->Servers




In the resulting dialog, click Add Server…




Click GlassFish Server 3+, then Next




Save it wherever you want, I went with the defaults, click Finish ( unless you want to change default settings ):




If all went well, you should see the following screen, simply click Close.




Now right click playndemo HTML and choose run. Now in the deployment dialog, you have a server you can select, do so and click OK:




And voila, your app running in a browser:




If you have problems or need to maintain or restart your GlassFish install, you can do so via the Window->Services menu option:




Running your PlayN Android Application in Netbeans


This part has a bit of a gotcha attached.  PlayN switched to use OpenGL 2.0 and the Android emulator simply doesn’t support Open GL 2.0 yet.  You can try to run it on the emulator, but it will crash every time.  If you have a physical device, you can get Netbeans to target it.


First right click playndemo and select Properties:



On the left hand side selection Actions.  In the Actions list, select Run Project.  Under Execute Goals: enter android:deploy android:run, and under Set Properties: enter skipTests=True and android.device=usb.  Finally click OK.  This is behind the scenes configuring a pair of maven commands.




Now with your Android phone plugged in, with USB debugging enabled, right click playndemo and choose Run.  Oddly enough, sometimes it deploys and runs the application, sometimes it simply deploys it and fails to run.  Worst case scenario, locate the app icon on your device and launch it manually.


Voila, PlayN running on my Galaxy Note  ( the black is because of the 1280x720 resolution ):





As you can see, you can successfully target all three platforms from Netbeans.  Trust me, that process looked a lot more complicated than it actually was.  Plus, you only have to do 95% of it once.


GFS On YouTube

See More Tutorials on!

Month List