Chapter 2. Working with 2D Graphics

In this chapter, we will cover the following recipes:

  • Texture rendering with SpriteBatch
  • More effective rendering with regions and atlases
  • Taking advantage of Libgdx sprites
  • Rendering sprite-sheet-based animations
  • Understanding orthographic cameras
  • Using ShapeRenderer for debug graphics
  • Handling multiple screen sizes with viewports

Introduction

Games are interactive experiences that provide feedback to the player mainly through visual elements and audio cues. As a result, rendering becomes one of the most important pillars games are built upon. This chapter will take us on a journey through the basics of the Libgdx 2D graphics API.

You will learn how to efficiently render both static and animated sprites and handle the ...

Get Libgdx Cross-platform Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.