Rendering a texture-filled polygon
When creating games with large levels it is often easy to run into memory limitations. Large maps also contain repetitive drawing of things like grass, trees, mountains, and so on. This recipe will show you how to efficiently render a polygon that is filled in with a repeated texture. These can be drawn at any size and still only use a small amount of memory and CPU time.
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" //Included for CPP polygon triangulation #import "triangulate.h" #include <stdio.h> ...
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.