The Terrain class
The Terrain
class is where we will do the most of our heavy lifting. This is the class that will create the hills in the game. When I say create, I mean give them that beautiful, colorful, materialistic appearance that you saw in the screenshot. In addition to that, this class will also generate the smooth curve of the hill and also create its physics body. Finally, it will be responsible for scrolling and scaling itself with respect to the penguin's position.
The Terrain
class will inherit from CCNode
. We will define this class in parts, starting with the most exciting part of all, the texture generation. We will then write code to generate the hills and the Box2D body. So, sharpen your pencils and smoothen your paintbrushes. Programmatic texture generation, here we come!
We will implement our Terrain
class in the following steps:
Generate a striped texture
Render the colored stripes
Render a gradient over the stripes
Render a highlight over the gradient
Render a thin border...