Applying primitives to a layer
AndEngine's primitive types include Line
, Rectangle
, Mesh
, and Gradient
objects. In this topic, we're going to focus on the Mesh
class. Meshes are useful for creating more complex shapes in our games which can have an unlimited amount of uses. In this recipe, we're going to use Mesh
objects to build a house as seen in the the following figure:
Getting ready…
Please refer to the class named ApplyingPrimitives
in the code bundle.
How to do it…
In order to create a Mesh
object, we need to do a little bit more work than what's required for a typical Rectangle
or Line
object. Working with Mesh
objects is useful for a number of reasons. They allow us to strengthen our skills as far as the OpenGL coordinate system goes, we can create oddly-shaped primitives, and we are able to alter individual vertice positions, which can be useful for certain types of animation.
The first step involved in creating
Mesh
objects is to create our buffer data which is used to specify the...