In this chapter, we will take a leap into a new direction and take things to the next level. You will learn how to programmatically generate textures and bind them to shapes so that they can be used in the game. Cocos2d-x is so flexible that it allows us to run our own rendering commands and we will take advantage of this fact.
In this chapter, you'll learn:
CCRenderTexture
class to draw into a textureIn our sixth game, Penguins Can Fly, we lead a cute little penguin through a wide expanse of vibrant, colorful, and breath-taking hills. The controls are quite simple, but the game takes some time to master. The player must simply tap the screen. Tapping the screen pulls the penguin towards the hill. Thus, the game becomes a skill-based judgment game where the player must learn the right moment to release the tap.
Quite a bit of code in this chapter has been ported to Cocos2d-x from a wonderful demo project (https://github.com/haqu/tiny-wings) in Cocos2d-iphone written by Sergey Tikhonov (http://haqu.net/). This demonstrates how some of the challenging features of the game are implemented. A lot of this chapter's explanation on the above demo project is inspired from an excellent tutorial written by Ali Hafizji on http://www.raywenderlich.com/. Please head out to these links if you want to take a look at the original. The original needs some understanding of Objective-C:
We will discuss the following entities in this chapter:
Terrain
classPenguin
classGameWorld
classThis is what we will achieve by the end of this chapter:
3.144.114.85