使用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
问题是什么?
答案 0 :(得分:2)
你的代码应该是
ChipmunkPointQueryInfo *info=[space pointQueryNearest:origin maxDistance:32.0f filter:CP_SHAPE_FILTER_ALL];
pointQueryNearest
没有返回数组,因为您试图枚举。
干杯。