用Chipmunk和cocos2d找到最近的点

时间:2015-03-04 09:11:53

标签: ios cocos2d-iphone chipmunk

使用cocos2d和chipmunk,我尝试在sprite(例如炸弹)周围获取不同的对象,这样我就可以对它们施加冲动。我首先在我的项目中添加了这个:

#import "ObjectiveChipmunk/ObjectiveChipmunk.h"
#import "CCPhysics+ObjectiveChipmunk.h"

然后是代码:

ChipmunkSpace *space = [_physicsNode space];
cpVect origin = item.position;
for(ChipmunkPointQueryInfo *info in [space pointQueryNearest:origin maxDistance:32.0f filter:CP_SHAPE_FILTER_ALL])
 {
CCLOG(@"Found one body"); 
}

我收到此错误:

 -[ChipmunkPointQueryInfo countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x813cdca0

问题是什么?

1 个答案:

答案 0 :(得分:2)

你的代码应该是

ChipmunkPointQueryInfo *info=[space pointQueryNearest:origin maxDistance:32.0f filter:CP_SHAPE_FILTER_ALL];

pointQueryNearest没有返回数组,因为您试图枚举。

干杯。