Sunday, April 7, 2013

Getting started with Eclipse and PlayN - run playn showcases

This article mentions how to set up eclipse for the work with the crossplatform game framework PlayN and also how to import and run the showcases.  
I decided to write this article since the Getting Started guide on http://code.google.com/p/playn/wiki/GettingStarted  is pretty short and some points were not quite clear to me as I was trying to set up Eclipse with PlayN. So I hope this guide will be helpful for you.

Some Information about my System :
  • OS: Ubuntu 12.04 LTS
  • Java: Open JDK 1.6
  • Eclipse Indigo

What is not covered in this article?  

Above all I was interested in the java, flash and html 5 functionality of PlayN. So I didn't test the ios and android targets. I your main interest lies in the mobile targets maybe this may be the wrong place for you. 

Set Up Maven Plugin

  •  First of all you need to install the Maven Plugin:  therefore click on Help -> Install New Software and type "maven" , the screen should look like this:
  • Select the item as shown in the picture, agree to install unsigned content if you'll be asked 

Another plugin you need is the native-dependency-plugin, to install it do the following:
  • In Eclipse click on: Help->Install New Software->Add (upper right corner)
  • The add "http://mavennatives.googlecode.com/svn/eclipse-update/" as new update site
  •  
  • Select the new Site, and the plugin to install  
  • install the plugin (accept to install unsigned content) 
  • Now we are done with the maven installation

 

Download and import the PlayN showcases

To download the showcases you need to install git. 
When the git installation was successful, we can checkout the showcases
  • Open a terminal (should also work on windows similarly) and cd to your eclipse workspace you want the showcases to be in
  • type : "git clone https://code.google.com/p/playn-samples"
If the download completed successfully there should be a directory named "playn-samples" and we can now import the samples in eclipse: 
  • In eclipse: click on File->Import.. 
  • Choose "Existing Maven Projects" and click on next
  • In the next screen click on "Browse" and browse to the previously mentioned "playn-samples" folder, select the subfolder "showcase" then on "ok" and on "Next" (later you can also try other samples from the "playn-samples" folder the same way)

  •  After this you see a summary of the required maven-plugins and eclipse tells you that one of them is missing (I wasn't able to find a way to resolve it). So we just click on "Finish".


  •  If all went right you should now see a bunch of new projects named "playn-showcase-x" 

Run the showcases

  • To run the showcases right click on playn-showcase->Run As -> maven install, As result the following should appear:

If you want to run the html version of the showcase
  • Previously make sure that the port 8080 is not already being used.
  • right click on playn-showcase-html->Run As -> maven install
  • Open a browser and type http://localhost:8080, now you should see the same menu and be able to play the samples

Notes

  • I haven't tried the android and ios targets
  • The flash target is not compiling (I will update the post when I have figured out what the problem is)
  • If you want to change the default port for the html target, just change the jetty-plugin configuration in pom.xml of the xx-html project to this: 
             
                org.mortbay.jetty
                jetty-maven-plugin
                8.0.0.v20110901
                
                    
                        ${project.basedir}/target/${project.artifactId}-${project.version}
                    
                    
                        
                            8181
                        
                    
                

                
                    
                        test-html
                        integration-test
                        
                            run-exploded
                        
                    
                
              
 

No comments:

Post a Comment