January 2015
Beginner to intermediate
478 pages
9h 46m
English
After making our assets, the next step is to allow our game to use them and load the texture atlas. Loading an asset such as a texture can be as simple as the following line of code:
Texture texture = new Texture(Gdx.files.internal("texture.png"));In the preceding example, we ask LibGDX to get an internal file handle to the texture.png file. Invoking an internal file means that LibGDX has to resolve the file's path by scanning the assets folder of the game. Then, the handle is passed over as an argument to the constructor of the Texture class to instantiate a new object of this type. This texture instance can now be directly rendered to the screen with another line of code, as shown in the following listing:
batch.draw(texture, ...
Read now
Unlock full access