Texture rendering with SpriteBatch

A texture is a bitmap image that gets applied to a surface through mapping. Rendering textures on the screen will be our first step in getting to know the Libgdx 2D graphics API. Once you learn a few simple operations with textures, you will be able to build relatively complex scenes for your games.

To illustrate the procedure, we are going to make use of a friendly caveman, who we will show at different positions, sizes, and orientations.

Getting ready

You need the samples projects to follow this recipe, so make sure you already have them in your Eclipse workspace. You will find the caveman texture in data/caveman.png, inside the data folder in the Android project.

How to do it…

The code for this recipe is hosted ...

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.