If we were to leave the background as it is, the game would look rather dull, with a black background. One option would be to simply drop in a background graphic to enhance the look. That would work, but we want to do something more dynamic to give the game some life. We will begin by using CCRenderTexture
to build a sprite with a grid pattern on it.
A
CCRenderTexture
can be thought of as a second "blank sheet of paper" on which we can draw primitive shapes (like lines), draw sprites upon, and generally do anything visual on it. The power of the CCRenderTexture
is that you can then use the resulting image as a sprite. One of the primary benefits for our project is that we can draw our grid on it once, and use it. If we were to put the
ccDrawLine
calls into our main layer's draw
method, it would be drawing them from scratch with every refresh. In our case, we are drawing the lines once, and then using the resulting textured sprite without the additional overhead...