存档

2009年8月 的存档

How can I test sprite collision in cocos2d?

2009年8月27日 没有评论

How do I start to implement a class for sprite collision?

You want to use the chipmunk’s physics engine, which is part of the cocos2d engine.

Example (iPhone)

You can also perform very simple collision detecting by checking if two rectangles intersect. You can use the CGRectIntersectsRect function to do this. Basically, both rects are based on the position and dimensions of sprites you want to check for collisions. If CGRectIntersectsRect returns true, you know a collision occurred.

More info here: [http://icodeblog.com/2009/02/18/iphone-game-programming-tutorial-part-2-user-interaction-simple-ai-game-logic/%5D%5B1%5D

As Eric pointed out, CGRectIntersectsRect is the method to test two bounding rects for overlapping. Use the boundingBox method of the CCNode classes to get the correct bounding box for each sprite (or other node).

See my answer here:
Collision Detection in Cocos2d game???

I would look into b2ContactListener

You can do some searches on that, and you’ll easily get some results

分类: cocos2d, stackoverflow精选 标签:

How do i use cocos2d with Xcode?

2009年8月10日 没有评论

I downloaded the lastest version of cocos2d but I am confused as to how to use it with my current project. Can anyone show me how to use it with xcode. I’m looking to design a 2D maze. Do i have to import something ? Any sort of help would be appreciated.

Yes, you need to drag the cocos2d files into your project, then they will be available.

This is a very helpful step-by-step resource on how to do that.

http://monoclestudios.com/cocos2d_whitepaper.html

As far as designing your game, get started, play around, and look at the sample code. There are also very helpful folks on the message board.

http://www.cocos2d-iphone.org/forum/

Good luck!

For the latest version of Cocos2D-iPhone (0.8.1) I’ve put together a tutorial at:
http://www.antonmills.com/?p=233

It includes everything you need for setting up the Xcode template, adding sprites and a small animation loop in a Hello World type of application, might be helpful :)

also deffinitely check the forum John posted, very helpful lot :)

Cheers,
anton.

分类: cocos2d, stackoverflow精选 标签: