i'm using chipmunk physics , want collision detection find out when 2 cpbodies collide. i've got questions;
- could give me example of using cpcollpairfunc or cpspaceaddcollisionhandler ?
- i've seen around rectangle intersection; possible polygons?
- should use library (spacemanager or whatever) on top?
thank you!
f.
you need add following lines
shape->collision_type = kcollisiontypeparticle;
cpspaceaddcollisionhandler(space_, kcollisiontypeparticle, kcollisiontypeparticle, collisondetect, null, null, null, self);
kcollisiontypeparticle enum can define if there 2 types of different particles.
typedef enum {
kcollisiontypeparticle,
kcollisiontypeparticlenew
} collisiontype;
here collisondetect method need register as:
cpbool collisondetect(cparbiter *arb, struct cpspace *space, void *data) {
*layer = ( *)data;
[layer collisondetect:arb];
return cptrue;
}
now here here handle rest of code
-(void)collisondetect:(cparbiter*)arb {
nslog(@"collision detected");
}
Comments
Post a Comment