Skip to content

matejmoravec/libgdx-sandbox

Repository files navigation

libGDX logo sandbox

Code is written in Java.

Why sandbox?

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.

A simple game

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.

Examples

Each example consists of files with code and a README file. README contains an explanation of the example.

List of examples within the sandbox:

How to run an example:

  1. Right-click on the selected DesktopLauncher class.

  2. Select 'Run DesktopLaunche....main()'. This should fail with missing assets because you need to hook up the assets folder first.

  3. Open up Run Configurations.

Edit configurations...

  1. 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.

Working directory

  1. Run application using the run button.

Summarized instructions from the libGDX page 'Importing & Running a Project'.

TexturePacker

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 the TextureAtlas 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
);  

Assets

List of assets used in the project:

About

Project designated as a sandbox to show libGDX principles.

Topics

Resources

Stars

Watchers

Forks

Languages