Animating a texture-filled polygon

The TexturedPolygon can also be easily animated. This is useful for animated crowds, ocean waves, bubbling lava pits, and so on. In the example we see an animated field of wheat.

Animating a texture-filled polygon

Getting ready

Please refer to the project RecipeCollection01 for full working code of this recipe.

How to do it...

Execute the following code:

#import "Vector3D.h" #import "TexturedPolygon.h" @implementation Ch1_AnimateTexturedPolygon -(CCLayer*) runRecipe { CGSize s = [[CCDirector sharedDirector] winSize]; ccTexParams params = {GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_REPEAT,GL_REPEAT}; //Create grass animated textured polygon CGPoint grassVertexArr[] ...

Get Cocos2d for iPhone 1 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.