//## initialisation of the static objects: levelobj[i].shape = [smgr addRectAt:cpv(levelobj[i].x,levelobj[i].y) mass:INFINITY width:levelobj[i].a height:levelobj[i].b rotation:levelobj[i].c]; levelobj[curobjtodrop].shape->collision_type=obj_passive; levelobj[i].node = [cpShapeNode nodeWithShape:levelobj[i].shape]; levelobj[i].node.color = ccc3(56+rand()%200, 56+rand()%200, 56+rand()%200); [self addChild:levelobj[i].node]; //## and movable objects: levelobj[i].shape = [smgr addRectAt:cpv(levelobj[i].x,levelobj[i].y) mass:levelobj[i].a*levelobj[i].b width:levelobj[i].a height:levelobj[i].b rotation:levelobj[i].c]; levelobj[curobjtodrop].shape->collision_type=obj_passive; levelobj[i].node = [cpShapeNode nodeWithShape:levelobj[i].shape]; levelobj[i].node.color = ccc3(56+rand()%200, 56+rand()%200, 56+rand()%200); [self addChild:levelobj[i].node]; //## adding collision callback: [smgr addCollisionCallbackBetweenType:obj_passive otherType:obj_active target:self selector:@selector(handleCollision:arbiter:space:) moments:COLLISION_BEGIN,nil]; [smgr addCollisionCallbackBetweenType:obj_active otherType:obj_passive target:self selector:@selector(handleCollision:arbiter:space:) moments:COLLISION_BEGIN,nil]; //## the handler: -(BOOL) handleCollision:(CollisionMoment)moment arbiter:(cpArbiter*)arb space:(cpSpace*)space{ NSLog(@"Kollision"); return YES; }