Hot File

Project setup, running and debugging

View: 469    Dowload: 0   Comment: 0   Post by: kulzxt  
Author: none   Category: Mobile applications   Fields: Game - Entertainment

0 point/1 review File has been tested

Attention: this is extremely outdated and NOT supported anymore! Please use the Gradle-based setup instead Libgdx is very Eclipse centric due to its Android and HTML5/GWT back-ends. This article discusses how to setup libgdx projects for Eclipse. Check out this Using libgdx with IntelliJ IDEA if you use IntelliJ. If you prefer to use a different IDE, please refer to the bottom of this page which outlines the dependencies in detail.

Introduction

Attention: this is extremely outdated and NOT supported anymore! Please use the Gradle-based setup instead

Libgdx is very Eclipse centric due to its Android and HTML5/GWT back-ends. This article discusses how to setup libgdx projects for Eclipse. Check out this Using libgdx with IntelliJ IDEA if you use IntelliJ. If you prefer to use a different IDE, please refer to the bottom of this page which outlines the dependencies in detail.

Prerequisites

To target Windows, Linux, Mac OS X, Android and HTML5 you will need:

To additionally target iOS you will also need:

  • A Mac, iOS Development does not work on Windows/Linux thanks to Apple.
  • The latest XCode, which you can get from the Mac OS X App Store for free
  • RoboVM, simply install the Eclipse plugin, or use the command line version.

Tutorial Video

Follow this if you don't want to read a lot of text. Otherwise continue below.

Libgdx setup video

Using "Libgdx Setup"

As of version 0.9.3, libgdx comes with an easy to use application called "Libgdx Setup" by Aurelien Ribon. The following steps will create everything needed to develop for the desktop, android, ios and html5.

  • Download the gdx-setup.jar from http://libgdx.badlogicgames.com/nightlies/dist/gdx-setup.jar. The jar is also contained in all stable and nightly releases.
  • Execute the jar by double clicking it or from the command line via java -jar gdx-setup.jar
    • Specify your project's configuration (Configuration Panel)
    • Specify the libgdx stable/nightly release zip file or press one of the buttons to download the latest stable/nightly release (Library Selection Panel).
    • Hit the "Generate projects" button (Generation Panel)
  • Open Eclipse and import the generated projects into your workspace
    • File -> Import -> Existing Projects into Workspace
    • Click "Browse", select the folder containing the generated projects.
    • Make sure all the projects are checked, then click "Finish"
    • To fix the error of the HTML5/GWT project, go to the "Problems" view, right click the error message "The GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory" and select "Quick Fix". Click "Finish".

Project Layout

Assuming you named your project "my-gdx-game" in the Setup UI, you will end up with 4 projects:

  • Core project ("my-gdx-game"): contains all the code of your application, minus the so called starter classes. All other projects link to this project. This project is usually referred to as the "core project".
  • Android project ("my-gdx-game-android"): contains the starter class and other necessary files to run your application on Android. The assets/ folder stores the assets of your application for all platforms.
  • Desktop project ("my-gdx-game-desktop"): contains the starter class to run your application on the desktop. Links to the Android project's assets/ folder as well as the core project.
  • HTML5 project ("my-gdx-game-html"): contains the starter class and other necessary files to run your application as a native HTML5 application. Links to the Android project's assets/ folder (see gwt.xml file) as well as to the core project.
  • iOS RoboVM project ("my-gdx-game-robovm"): contains the starter classes and other necessary files to run your application on iOS through RoboVM. Links to the Android project's assets/ folder (see robovm.xml) as well as the core project.

All your application's assets should be stored in the Android project's assets folder. The desktop, iOS and HTML5 projects link to this folder, so there is no need to store duplicates of these assets.

Running Your Application

  • Desktop: Right click the desktop project, Run As -> Java Application. Select the desktop starter class (e.g. Main.java).
  • Android: make sure you have a device connected and that it shows up in DDMS. If you do not know what this means, please refer to the Android Developer Guide. Right click your Android project, Run As -> Android Application.
  • iOS RoboVM: Right click the robovm project, Run As -> iOS Device App to run on a connected device, or Run As -> iOS Simulator App to run on the iOS simulator. If you run on a device, you need to provision it to be able to deploy to it!
  • HTML5: there are two modes in which you can run your application.
    • development/hosted mode: runs the actual Java code via GWT plugin magic and allows debugging and hot swapping code (kind of).
      • Right click the HTML5 project, Run As -> Web Application.
      • In the "Web Development" view, click the URL. Your standard browser will open up. If you have not installed the GWT plugin yet, you will be prompted to do so. After installation of the plugin, simply refresh the site in the browser.
    • production/web mode: you will need a web server that serves the compiled files (e.g.Nginx or a browser that allows to execute JavaScript from local files.
      • Right click the HTML5 project, Google -> GWT Compile
      • Once compiled, place the contents of the war/ directory into a directory your web server can serve. Omit the WEB-INF folder.
      • Point your browser at an URL which will display the .html file.

Debugging Your Application

  • Desktop: Right click the desktop project, Debug As -> Java Application. Select the desktop starter class (e.g. Main.java). Set breakpoints where you need them, hot swap code (edit & save while debugging) to quickly test changes without restarting the app.
  • Android: assuming you have a device connected, Debug As -> Android Application. Hot swapping is not supported, but you can use the DDMS perspective to check your memory usage, profile your application and so on. Refer to the Android Development Guide for more information.
  • iOS RoboVM: debugging is currently not supported by RoboVM
  • HTML5:
    • development/hosted mode: runs the actual Java code via GWT plugin magic and allows debugging and hot swapping code (kind of).
      • Right click the HTML5 project, Debug As -> Web Application.
      • In the "Web Development" view, click the URL. Your standard browser will open up.
      • Set breakpoints in your Java code. If you edit & save code, you'll have to refresh your browser for the changes to take effect. This will essentially restart your application. It's faster than recompiling though.
    • production/web mode:
      • Right click the HTML5 project, Google -> GWT Compile
      • Change the flags in "Advanced" to -strict -draftCompile and the "Output Style" to "detailed". This will produce very readable Javascript that you can map almost 1:1 to your Java code.
      • Once compiled, place the contents of the war/ directory into a directory your web server can serve. Omit the WEB-INF folder. # Point your browser at an URL which will display the .html file. # Open up Firebug or similar tools, go to the JavaScript and set breakpoints, watch the callstack and so on. To find a Java Class method, simply search for the package/class/method name.
    • super dev mode: through the power of source maps, you can also debug compiled JS as if it where Java, directly in your browser. See this blog post on libgdx and super dev mode

Manual Project Setup

Please refer to Manual Project Setup

Project setup, running and debugging

Project setup, running and debugging Posted on 12-11-2016  Attention: this is extremely outdated and NOT supported anymore! Please use the Gradle-based setup instead Libgdx is very Eclipse centric due to its Android and HTML5/GWT back-ends. This article discusses how to setup libgdx projects for Eclipse. Check out this Using libgdx with IntelliJ IDEA if you use IntelliJ. If you prefer to use a different IDE, please refer to the bottom of this page which outlines the dependencies in detail. 5/10 469

Comment:

To comment you must be logged in members.

Files with category

  • Start classes & configuration

    View: 294    Download: 0   Comment: 0   Author: none  

    Start classes & configuration

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    For each target platform, a starter class has to be written. This class instantiates a back-end specific Application implementation and the ApplicationListener that implements the application logic. The starter classes are platform dependent, let's...

  • Project setup Guide

    View: 488    Download: 0   Comment: 0   Author: none  

    Project setup Guide

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review

  • Using libgdx with intellij idea

    View: 447    Download: 0   Comment: 0   Author: none  

    Using libgdx with intellij idea

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    The newest, and easiest way to setup libgdx for use with IntelliJ IDEA is to use the gradle build system. A detailed tutorial can be read here

  • Start classes & configuration

    View: 401    Download: 0   Comment: 0   Author: none  

    Start classes & configuration

    Category: Mobile applications
    Fields: Game - Entertainment

    0/2 review
    For each target platform, a starter class has to be written. This class instantiates a back-end specificApplication implementation and the ApplicationListener that implements the application logic. The starter classes are platform dependent, let's...

  • Project setup, running and debugging

    View: 469    Download: 0   Comment: 0   Author: none  

    Project setup, running and debugging

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    Attention: this is extremely outdated and NOT supported anymore! Please use the Gradle-based setup instead Libgdx is very Eclipse centric due to its Android and HTML5/GWT back-ends. This article discusses how to setup libgdx projects for Eclipse....

  • The applications framework

    View: 406    Download: 0   Comment: 0   Author: none  

    The applications framework

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    At its core, libgdx consists of six interfaces that provide means to interact with the operating system. Each back-end implements these interfaces.

  • Start Building libgdx from source

    View: 403    Download: 0   Comment: 0   Author: none  

    Start Building libgdx from source

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    Before trying to build libgdx from source yourself, you'll have to install Eclipse and all other related software. We currently don't support development with other IDEs. In addition you'll have to install Ant and make sure its bin/ directory is...

  • Start Build Infrastructure Setup

    View: 499    Download: 0   Comment: 0   Author: none  

    Start Build Infrastructure Setup

    Category: Mobile applications
    Fields: Game - Entertainment

    0/1 review
    Our build infrastructure has the responsibility of building libgdx for all supported platforms (Windows, Linux, Mac OS X, Android, iOS, HTML). On top of the boring old Java code, we also need to compile the native code for each platform and...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd