Using textured meshes
Textured meshes, which are simply triangulated polygons with a texture applied, are becoming more popular in mobile games because they allow for the creation and manipulation of non-rectangular shapes. Having the ability to work with textured meshes often creates an extra layer of game mechanics that were previously too costly to implement. In this recipe, we will learn how to create a textured mesh from a predetermined set of triangles.
Getting ready...
First, create a new activity class named TexturedMeshActivity
that extends BaseGameActivity
. Next, place a seamless-tiling texture named dirt.png
with the dimensions 512 x 128 in the assets/gfx/
folder of our project. Finally, import the TexturedMesh.java
class from the code bundle into our project.
How to do it...
Follow these steps to build our TexturedMeshActivity
activity class:
Place the following code in our activity to give us a standard AndEngine activity:
@Override public EngineOptions onCreateEngineOptions() {...