Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


6. November 2011

 

 

Hmm, kinda realized I missed this part in my recent PlayN installer post.  After you go ahead and create your game, it creates a new project hierarchy and… then what?  This post shows the various ways you can start your game.

 

Assuming you used my installer to install PlayN, you can run your game from the command line using the following steps.  I will assume your game’s name was “mygame” in these examples and that you installed to c:\playn.

 

 

 

Running the desktop Java app with Maven

 

 

cd playn\playn\mygame\core

..\..\..\maven\apache-maven3.0.3\bin\mvn install compile exec:java

 

 

Running the HTML target with Maven

 

cd playn\playn\mygame

..\..\maven\apache-maven3.0.3\bin\mvn package  ( wait, this takes a bit )

..\..\maven\apache-maven3.0.3\bin\mvn –Ptest-html

 

This will currently through a bunch of errors in your face since the Flash build seems to currently be broken, ignore them.  Once you run that second command, a web server Jetty will be downloaded and installed.

 

Now open a browser and go to http://localhost:8080 to see your game running in a browser.

 

When done, you can use CTRL+C in the dos window to get Jetty to stop.

 

Running the Flash target with Maven

 

You can’t, it’s currently broken, I’m looking into it and will update with details or a fix if possible.

 

Running the Android target with Maven

 

This process is a bit too involved and requires other steps ( like configuring the emulator or a physical device, which we didn’t do during the initial install.  I will cover this in detail in a later post.

 

There is a problem in that the fact Flash is broken, and before Android in the build order, your Android target will never be built!  This can easily be fixed by opening pom.xml in your game folder and remove the line <module>flash</module>.

 

Running the Java and HTML targets with Ant

 

If you have Apache ant installed, you can also use it to run Java and HTML targets. Currently you cannot run Flash or Android this way.

 

Running desktop:

cd playn\playn\mygame

ant

 

Running HTML:

cd playn\playn\mygame

ant run-html

 

Just like with Maven ( but a whole lot quicker ) it runs Jetty and you can reach your website using a browser.  However, unlike the maven install, for some reason the ant install is in a subdirectory, so your URL is http://localhost:8080/mygame.

 

 

Of course, if you are using an IDE like Eclipse or NetBeans, they can automate many of these tasks.  If you add Maven’s bin folder to your PATH variable, it will save you a ton of typing.  Of course you could also make a simply script to run your game in a much more terse syntax.

Programming

blog comments powered by Disqus

Month List

Popular Comments