1

I am building a cocos2d iPhone game.

There will be 6 'enemy spaceship sprites' that vary only by colour. I.e. all the sprites will have the same shape only some parts of the interior will have different colours.

My two options are:

1)

  • Create a template shape with a transparent interior.
  • At runtime, draw this shape on top of a small block of colour X.
  • The interior of the sprite will be colour X.

2)

  • Pre-render 6 different sprites
  • At run time, simply draw the sprite of a given colour.

What is the advantages and disadvantages of each method? Is there a best practice?

If I later wanted to animate the sprites, or dynamically change their colours, would this effect my choice of method?

Thanks!

Robert
  • 37,670
  • 37
  • 171
  • 213

1 Answers1

1

I think first you need to figure out what it is that you're trying to do... Animation or a large number of color combinations make pre-rendering unfeasible. On the other hand, pre-rendering makes sense if you have a large number of ships on-screen at the same time, because you can use this technique to cut the number of drawing operations in half.

martona
  • 5,760
  • 1
  • 17
  • 20