开发者

Chipmunk: How to remove shape and body?

First, sorry for my English, im not an American. My question is how can I remove the shape and body from the space, this isn't related with collision detection. Im triying to do this with a touch event, specifically I'm trying to clear a ball Touching it (I have a lot of balls in the space), but I have no idea how to do it, I have been looking on Internet and cannot find any help regarding how to do it, all relates to the collisions and that's not what I need.

I read many times the documentation, but not contain any useful information how to do this. Only have how delete with colission. I know how delete with coliss开发者_高级运维ion:

static void postStepRemove (cpSpace *space, cpShape *shape, void *data) {

//Remove the shape and body
cpSpaceRemoveBody(space, shape->body);
cpBodyFree(shape->body);
cpSpaceRemoveShape(space, shape);
cpShapeFree(shape);

}

static int collission(cpArbiter *arb, cpSpace *space, void *data){

     cpShape *a, *b;

 cpArbiterGetShapes(arb, &a, &b);

    cpSpaceAddPostStepCallback(space, (cpPostStepFunc)postStepRemove, a, nil);
    cpSpaceAddPostStepCallback(space, (cpPostStepFunc)postStepRemove, b, nil);
    return 0;
}
return 1;

}

I use this with collision, but I need some example without collision.


Find the library documentation and read the damn manual: Chipmunk physics documentation

cpBodyFree and cpShapeFree seem to be the API calls you need. Cocos2d likely has some bindings on calling them. Locate Cocos2D documentation if you need to know more about those calls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜