Code is written in Java.
The idea of the sandbox is to show basic libGDX principles with whose you can play. You can download the code, run examples and try to change its configuration, and have a better understanding of a specific principle.
The project consists of a simple Piggy bank game whose idea is to collect as many coins as possible and avoid hammers. The game uses a few different principles without going into unnecessary details.
Each example consists of files with code and a README file. README contains an explanation of the example.
-
Right-click on the selected DesktopLauncher class.
-
Select
'Run DesktopLaunche....main()'
. This should fail with missing assets because you need to hook up the assets folder first. -
Open up Run Configurations.
- Edit the Run Configuration that was just created by running the desktop project and setting the working
directory to point to the
android/assets
folder.
- Run application using the run button.
Summarized instructions from the libGDX page 'Importing & Running a Project'.
Explanation of TexturePacker
from libGDX Wiki:
In OpenGL, a texture is bound, some drawing is done, another texture is bound, more drawing is done, etc. Binding the texture is relatively expensive, so it is ideal to store many smaller images on a larger image, bind the larger texture once, then draw portions of it many times. libGDX has a
TexturePacker
class which is a command line application that packs many smaller images on to larger images. It stores the locations of the smaller images so they are easily referenced by name in your application using theTextureAtlas
class.
Example on how you can use TexturePacker class you can find in AssetPacker class inside desktop project.
Code snippet from the class with arguments of process
method explained:
TexturePacker.process(settings,
RAW_ASSETS_PATH + "/scene2d", // the directory containing individual images to be packed
ASSETS_PATH + "/scene2d", // the directory where the pack file will be written
"scene2d" // the name of the pack file / atlas name
);
List of assets used in the project: