All pastes #2054574 Raw Edit

Mine

public text v1 · immutable
#2054574 ·published 2011-05-06 15:26 UTC
rendered paste body
//## 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;
}