views:

79

answers:

2

Hello, I am new to iPhone dev and would like to write a game that involves 2d collisions. Would somebody give me a conceptual overview on how the various frameworks interact in a typical 2d collision game?

The candidates I see mentioned so far are 2d packages such as quartz and cocos2d and physics engines such as chipmunk and box2d. What I am not extremely clear is the relationships among these in my context.

Thanks in advance for answering!

+1  A: 

Quartz is a 2D graphics API by Apple. It's usually not used for performance-intensive games, because you can get better performance by using OpenGL directly or by using some thin framework made for games. (Which is what Cocos2D provides.) The collision stuff is independent on this debate, since the collisions are usually calculated without knowing anything about the graphic representation of the colliding objects.

The relationship between collision (or general physics) engines and the graphic layer is exactly the relationship between a model and a view in the MVC pattern. In each frame you move the physical world a bit forward (physics) and then you draw the objects on their new positions (graphics).

In reality the model and view sometimes blend a bit to make things faster, but in principle they are completely separate things. Which means you can pick any of the possible combinations of OpenGL, Quartz or Cocos2D as the graphics engine and Box2D or Chipmunk as the physics engine and get a decent game. I'm not sure how well do the particular combinations work in practice - if that was your question, then I've just wasted a few minutes of your life :-)

zoul
Awesome answer!
Delta2038
A: 

zoul got it right, I would just add this :

Cocos2d for iPhone provides samples including Box2D and Chipmunk if you want to try them and see how easy or hard they are to use. So you can go ahead and download Cocos2d, then play with the samples a bit to see if it fits your needs.

jv42
Thanks a lot! All great answers. I've since played with a Cocos2D+Box2D tutorial and am now much clearer on the concept.
Delta2038
I'm glad :) SO tip: if you accept an answer, you'll gain reputation. With more reputation, you'll be able to vote up useful answers ;)
jv42