Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering LibGDX Game Development

You're reading from   Mastering LibGDX Game Development Leverage the power of LibGDX to create a fully functional, customizable RPG game for your own commercial title

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781785289361
Length 420 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Patrick Hoey Patrick Hoey
Author Profile Icon Patrick Hoey
Patrick Hoey
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. As the Prophecy Foretold, a Hero is Born 2. Welcome to the Land of BludBourne FREE CHAPTER 3. It's Pretty Lonely in BludBourne… 4. Where Do I Put My Stuff? 5. Time to Breathe Some Life into This Town 6. So Many Quests, So Little Time… 7. Time to Show These Monsters Who's the Boss 8. Oh, No! Looks Like Drama! 9. Time to Set the Mood 10. Prophecy Fulfilled, Our Hero Awaits the Next Adventure Index

Running the default demo project

Now that we have an overview of the project structure, we can now run the project sample to make sure that your project is configured correctly, is building, and can run.

You can either double-click on the BludBourne.ipr file in the project root directory or launch your IDE and import the BludBourne project. In order to import with IDEA, execute the following steps:

  1. Choose File | New | Project From Existing Sources. Choose the root directory of your project in the Select File or Directory to Import dialog. Click on OK.
  2. In the Import Project dialog, select Create project from existing sources and click on Next.
  3. On the next page of the wizard, give your project a name on the Import Project dialog. Click on Next.
  4. If source files have been detected, make sure they are selected in the Import Project dialog. Click on Next.
  5. Make sure the gradle-wrapper library is found at this stage with the Import Project dialog. Click on Next.
  6. Make sure the module structure includes both the core and desktop modules in the Import Project dialog. Click on Next. You may get a popup dialog asking whether to overwrite or reuse the files. I would recommend the reuse option.
  7. Select the proper Java project SDK in the next Import Project dialog. Click on Next.
  8. On the last page of the wizard, click on Finish.

If you are running IDEA, and you committed the initial project to Git, you may see the following Gradle-based balloon notification when you start the IDE for the first time:

Unregistered VCS root detected 
The directory C:\BludBourne is under Git, but is not registered in the Settings.

In order to resolve this, with the project open, go to File | Settings. Under the Settings dialog, select Version Control. Your project should be listed under Directory on the right panel, under Unregistered roots. Select your directory and click on the + button on the right. Select Apply and OK when finished.

If you are running IDEA, you may also see a Gradle-based balloon notification when you start the IDE for the first time:

Unlinked Gradle project?
       Import Gradle project, this will also enable Gradle Tool Window.
       Don't want to see the message for the project again: press here.

Click on the Import Gradle project link (in the balloon notification at the bottom). In the Import Project from Gradle dialog, make sure that your root project build.gradle is configured in the Gradle Project path. Also, make sure the Use default gradle wrapper (recommended) option is enabled. Change the Project format: option to .ipr (file based). Click on OK when finished.

If you are running IDEA, you may also come across this Gradle-based notification when starting the IDE with a clone of the BludBourne project repository:

Error:Unable to make the module: <module>, related gradle configuration was not found. 
Please, re-import the Gradle project and try again.

In order to resolve this issue, go to View | Tool Windows | Gradle. Click on the refresh button in order to synchronize all linked projects.

In IDEA, select Build | Make Project. You should now have successfully built the startup project. We will now need to create a run target:

  1. Select Run | Edit Configurations from the menu in IDEA.
  2. Click on the + icon in the upper-left corner and choose Application.
  3. You will be presented with the Run/Debug Configurations dialog.
  4. You should give your run target a name, such as Run.
  5. You will need to update the Main class: setting with DesktopLauncher.
  6. You will also need to set the Working directory: path to <project root>\core\assets. If you don't set this, you will get the following runtime error:
    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
       at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
       at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
  7. You will need to set the Use classpath of module option to Desktop since this is where the main entry point of your game lives.
  8. Click on OK when finished.

Now, everything should be configured to finally run. From the menu, select Run | Run target. If all the dependencies are correct, with a proper Gradle build setup and project configuration, you should see the following screen (Figure 10):

Running the default demo project

Figure 10

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime