Search code examples
iphoneobjective-ccore-animation

For a real time game, Should I use core animation or redraw images frequently?


Say I have to move a image across the screen according to user input....

Should I?

  • Use core animation periodically to animate the movement in small chunks.

Or

  • Redraw the image frequently at different locations.

If there is no clear answer, what are the advantages of using each method?


Solution

  • CoreAnimation is not generally made for game programming, and doesn't have the performance characteristics that it generally takes to make a real, playable game. You may be able to make a very basic game very easily with CoreAnimation, but it's likely that at some point you will run into these performance limitations, and at that point you will probably need to rewrite your codebase using a real gaming engine.

    To be clear, CoreAnimation is amazing and is ideally suited to the task for which it was created, which is application UI development. But it doesn't take much in terms of sprite count and size before you hit the performance wall when using it in a game. I say this because I have tried it.

    My recommendation is to use one of the easy, off-the-shelf gaming engines available on iOS, like Cocos2D, to write your game. It's easy enough for a relative beginner, but is more suited to game development both in terms of performance characteristics and API.