Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone board game: OpenGL ES or CoreGraphics? [closed]

I want to program a board game (similar to checkers) for the iPhone. Would OpenGL ES or CoreGraphics be a better option? What do most games of this type on the App Store use?

like image 320
titaniumdecoy Avatar asked Jul 04 '09 16:07

titaniumdecoy


2 Answers

Actually, what I'd suggest in this case is Core Animation or even just UIViews themselves. If you do direct drawing of all of your elements in a single view via Core Graphics, then refresh that view for every animation frame, you'll get horrible performance.

I'd suggest drawing the discrete elements of the game board (pieces, counters, board squares, etc.) as individual UIViews or CALayers, then animating those layers or views around. UIViews aren't too much heavier than CALayers, and they use Core Animation behind the scenes to do simple movement, scaling, or fading animations. They can also respond to touch events. CALayers are useful if you want to build a more cross-platform (Mac and iPhone) game, or if you need to do more complex animations.

For a 2-D game, I'd hold off on OpenGL until you were absolutely sure that you couldn't get the kind of performance you want from Core Animation. OpenGL is a lot less elegant to code for.

For a good example of how to do a board game using Core Animation, Apple has provided the GeekGameBoard sample code. Although it's a Mac application, the Core Animation code can translate right across to the iPhone.

like image 61
Brad Larson Avatar answered Oct 05 '22 23:10

Brad Larson


You might also check out cocos2d for iphone - it's a pretty full-featured 2d game library; it's got tilemaps, sprites, parallax, scheduling, etc. I'm using it for my game, and it's helped me quite a bit.

http://code.google.com/p/cocos2d-iphone/

like image 39
John Avatar answered Oct 06 '22 00:10

John