Learning Libgdx Game Development

Book description

Are your games limited to one platform? Use our practical guide to libGDX and before long you’ll be developing games that run across multiple platforms, enjoying an increased audience and revenue.

  • Create a libGDX multi-platform game from start to finish
  • Learn about the key features of libGDX that will ease and speed up your development cycles
  • Write your game code once and run it on a multitude of platforms using libGDX
  • An easy-to-follow guide that will help you develop games in libGDX successfully

In Detail

Game development is a field of interdisciplinary skills, which also makes it a very complex topic in many respects. One decision that usually needs to be made at the beginning of a game development processis to define the kind of computer system or platform the game will be developed for. This does not pose any problems in general but as soon as the game should also be able to run on multiple platforms it will become a developer’s nightmare to maintain several distinct copies of the same game. This is where the libGDX multi-platform game development framework comes to the rescue!

"Learning libGDX Game Development" is a practical, hands-on guide that provides you with all the information you need to know about the libGDX framework as well as game development in general so you can start developing your own games for multiple platforms. You will gradually acquire deeper knowledge of both, libGDX and game development while you work through twelve easy-to-follow chapters.

"Learning libGDX Game Development" will walk you through a complete game development cycle by creating an example game that is extended with new features over several chapters. These chapters handle specific topics such as organizing resources, managing game scenes and transitions, actors, a menu system, using an advanced physics engine and many more. The chapters are filled with screenshots and/or diagrams to facilitate comprehension.

"Learning libGDX Game Development" is the book for you if you want to learn how to write your game code once and run it on a multitude of platforms using libGDX.

Table of contents

  1. Learning Libgdx Game Development
    1. Table of Contents
    2. Learning Libgdx Game Development
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Introduction to Libgdx and Project Setup
      1. Diving into Libgdx
      2. Features of Libgdx 0.97
        1. Graphics
        2. Audio
        3. Input Handling
        4. File I/O
        5. Math and Physics
        6. Utilities
        7. Tools
      3. Getting in touch with the community
      4. Prerequisites for installing and configuring
        1. Java Development Kit (JDK)
        2. Eclipse – Integrated Development Environment (IDE)
        3. Downloading Libgdx
        4. Installing Android SDK
        5. Running Eclipse and installing plugins
      5. Creating a new application
      6. Kicking your game to life
      7. Key to success lies in planning
      8. Game project – Canyon Bunny
        1. Description of the game
      9. Summary
    9. 2. Cross-platform Development – Build Once, Deploy Anywhere
      1. The demo application – how the projects work together
      2. Backends
        1. LWJGL (Lightweight Java Game Library)
        2. Android
        3. WebGL
      3. Modules
        1. The application module
          1. Logging
          2. Shutting down gracefully
          3. Persisting data
          4. Querying the Android API Level
          5. Querying the platform type
          6. Querying memory usage
        2. Graphics module
          1. Querying delta time
          2. Querying display size
          3. Querying the FPS (frames per second) counter
        3. Audio module
          1. Sound playback
          2. Music streaming
        4. Input module
          1. Reading the keyboard/touch/mouse input
          2. Reading the accelerometer
          3. Starting and canceling vibrator
          4. Catching Android soft keys
        5. The files module
          1. Getting an internal file handle
          2. Getting an external file handle
        6. The network module
          1. HTTP GET and HTTP POST
          2. Client/server sockets
          3. Opening a URI in a web browser
      4. Libgdx's Application Life-Cycle and Interface
      5. Starter Classes
        1. Running the demo application on a desktop
        2. Running the demo application on Android
        3. Running the demo application in a WebGL-capable web browser
      6. The demo application – time for code
        1. Inspecting an example code of the demo application
          1. The create() method
          2. The render() method
          3. The dispose() method
        2. Having fun with the debugger and Code Hot Swapping
      7. Summary
    10. 3. Configuring the Game
      1. Setting up the Canyon Bunny project
      2. Using a class diagram for Canyon Bunny
      3. Laying foundations
        1. Implementing Constants
        2. Implementing CanyonBunnyMain
        3. Implementing WorldController
        4. Implementing WorldRenderer
      4. Putting it all together
        1. Building the game loop
        2. Adding test sprites
        3. Adding game world's debug controls
        4. Adding CameraHelper
        5. Adding camera debug controls using CameraHelper
      5. Summary
    11. 4. Gathering Resources
      1. Setting a custom Android application icon
      2. Creating texture atlases
      3. Loading and tracking assets
      4. Organizing assets
      5. Testing assets
      6. Handling level data
      7. Summary
    12. 5. Making a Scene
      1. Creating game objects
        1. The rock object
        2. The mountains object
        3. The water overlay object
        4. The clouds object
      2. Implementing the level loader
      3. Assembling the game world
      4. Implementing the game GUI
        1. The GUI score
        2. The GUI extra lives
        3. The GUI FPS counter
        4. Rendering the GUI
      5. Summary
    13. 6. Adding the Actors
      1. Implementing the actor game objects
        1. Creating the gold coin object
        2. Creating the feather object
        3. Creating the bunny head object
        4. Updating the rock object
      2. Completing the level loader
      3. Adding the game logic
        1. Adding collision detection
        2. Losing lives, game over, and fixing the camera
        3. Adding the game over text and the feather icon to the GUI
      4. Summary
    14. 7. Menus and Options
      1. Managing multiple screens
      2. Exploring Scene2D (UI), TableLayout, and skins
      3. Using Libgdx's scene graph for the menu UI
      4. Building the scene for the menu screen
        1. Adding the background layer
        2. Adding the objects layer
        3. Adding the logos layer
        4. Adding the controls layer
        5. Adding the Options window layer
      5. Building the Options window
        1. Using the game settings
      6. Summary
    15. 8. Special Effects
      1. Creating complex effects with particle systems
      2. Adding a dust particle effect to the player character
      3. Moving the clouds
      4. Smoothing with Linear interpolation (Lerp)
        1. Letting the rocks float on the water
      5. Adding parallax scrolling to the mountains in the background
      6. Enhancing the game screen's GUI
        1. Event – player lost a life
        2. Event – score increased
      7. Summary
    16. 9. Screen Transitions
      1. Adding the screen transition capability
        1. Implementing transition effects
        2. Knowing about interpolation algorithms
        3. Creating a fade transition effect
        4. Creating a slide transition effect
        5. Creating a slice transition effect
      2. Summary
    17. 10. Managing Music and Sound Effects
      1. Playing back music and sound effects
        1. Exploring the Sound interface
        2. Exploring the Music interface
      2. Accessing the audio device directly
        1. Exploring the AudioDevice interface
        2. Exploring the AudioRecorder interface
      3. Using sound generators
        1. About the sfxr generator
        2. About the cfxr generator
        3. About the bfxr generator
      4. Adding music and sounds to Canyon Bunny
      5. Summary
    18. 11. Advanced Programming Techniques
      1. Simulating physics with Box2D
        1. Exploring the concepts of Box2D
          1. Understanding rigid bodies
          2. Choosing body types
          3. Using shapes
          4. Using fixtures
          5. Simulating physics in the world
        2. Physics body editor
        3. Preparing Canyon Bunny for raining carrots
          1. Adding the new assets
          2. Adding the carrot game object
          3. Adding the goal game object
          4. Extending the level
        4. Letting it rain carrots
      2. Working with shaders in Libgdx
        1. Creating a monochrome filter shader program
        2. Using the monochrome filter shader program in Canyon Bunny
      3. Adding alternative input controls
      4. Summary
    19. 12. Animations
      1. Manipulating actors through actions
        1. Actions for manipulating actors
        2. Controlling the order and time of execution
      2. Animating the menu screen
        1. Animating the gold coins and bunny head actors
        2. Animating the menu buttons and options window
      3. Using sequences of images for animations
        1. Packing animations using the texture packer
        2. Choosing between animation play modes
      4. Animating the game screen
        1. Defining and preparing new animations
        2. Animating the gold coin game object
        3. Animating the bunny head game object
      5. Summary
    20. Index

Product information

  • Title: Learning Libgdx Game Development
  • Author(s): Andreas Oehlke
  • Release date: September 2013
  • Publisher(s): Packt Publishing
  • ISBN: 9781782166047