3. Use gradle to create a libgdx Project

Source: Internet
Author: User
Tags libgdx netbeans

Original article: http://www.libgdx.cn/topic/20/3-%E4%BD%BF%E7%94%A8gradle%E5%88%9B%E5%BB%BAlibgdx%E9%A1%B9%E7%9B% AE /2

Create a libgdx Project
Libgdx projects can be created using a file called a gdx-setup.jar, GDX-setup is a graphical Java program, and can also be executed under the command line. You only need to execute this jar file to open the graphic interface. If you want to use the command line format:
Java-jar gdx-setup.jar

Click to download the latest gdx-setup.jar

Enter the name of your application, the name of your Java package, the main class of your application, the output folder and the location of your android SDK.
Next, select the platform to be supported. (Note: Once the selection is complete, if you need to add a new platform, you need to manually add it !).
Finally, select the desired extension package (some extension packages cannot run on some platforms. If this happens, you will be prompted ).
After setting all the tasks, click "generate ".
(Because access to gradle in China is slow, it may take a long time to generate a project for the first time, so be patient. Then the speed is faster .)
After the build is complete, you can now import the generated project to your ide (Eclipse, intellij idea or netbeans), run, debug, or package for release!

  • Eclipse

  • Intellij idea

  • Netbeans

  • Command Line

Create a libgdx project using the command line
If you use command line to create a project, read the instructions below.

  • Dir: the location where your project is created.

  • Name: the name of the application you created, preferably in lower case, such as game.

  • Package: Java package name. For example, CN. libgdx. Game.

  • Mainclass: name of your main class. For example, game (remember, the first letter of the class is capitalized ).

  • Sdklocation: the location of your android SDK.

In addition, you can generate a libgdx project through the command line. As follows:
Java-jar gdx-setup.jar -- dir game -- name game -- package CN. libgdx. Game -- mainclass game -- sdklocation SDK installation location
(Note: The SDK installation location refers to the location where you install the SDK. For example, D: \ Android \ SDK)

Project directory structure
After you perform the preceding operations, a game folder is generated. The directory structure is as follows:

Settings. gradle <-define a supported platform.
Build. gradle <-gradle main Build File, defining dependencies and plug-ins
Gradlew <-run this script on Unix-like systems (Mac OS X and Linux)
Gradlew. Bat <-run this script on Windows
Gradle <-local gradle Encapsulation
Local. properties <-defines the location of the android SDK for intellij idea files.

Core/
Build. gradle <-gradle Build File for core projects
Src/<-code folder

Desktop/
Build. gradle <-gradle build file of the desktop project
Src/<-desktop project code folder, letter of guarantee lwjgl startup class

Android/
Build. gradle <-gradle build file of the android Project
Androidmanifest. xml <-android configuration file
Assets/<-contains your images, sounds, and so on. Resources in this folder are shared with other projects.
Res/<-included icon file
Src/<-android project source code, including the android startup class

Html/
Build. gradle <-The gradle build file of the HTML Project
Src/<-HTML project source code, including startup and definition
Webapp/<-contains the startup URL and web. xml

IOS/
Build. gradle <-gradle Build File of IOS Project
Src/<-Ios project source code, including startup

* The gradle script is set for a specific platform. If you are not familiar with gradle, do not change it at will.

What is gradle?

Gradle is a dependency management and building system.
A dependency management system can easily add third-party libraries to your project without adding third-party libraries to the library folder of your project. Build a version that depends on a specific file under the project to specify the name of a third-party library. This makes managing third-party dependent libraries very simple. The dependency management system downloads the library files you need from the central repository and saves them to a folder other than your project (libgdx uses Maven ).
Building a system helps you build and package applications without any IDE.
(Www.libgdx.cn is copyrighted. If you need to reprint it, indicate the source)

3. Use gradle to create a libgdx Project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.