Help determining if a shape is multi-shaped or not.
Posted: Tue Feb 16, 2010 11:55 pm
Hello all.
I would like to have shapes which will disappear when clicked. The shapes are stored in Objective-C objects and are created with member functions like so:
The problem is, the shape created by this is not an Objective-C object, it is a 'cpsShape' so I can't have a member function in my Objective-C object that will remove the shape and all of its 'sub-shapes'. I can't think of how to ask the cpShape if it has multiple shapes associated with it that need to be deleted ( and if so how many).
Any idea's on how I could go about this would be greatly appreciated!
I would like to have shapes which will disappear when clicked. The shapes are stored in Objective-C objects and are created with member functions like so:
Code: Select all
#import "SCross.h"
@implementation SCross
- (id)init{
UIImageView *temp = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SCross.png"]];
temp.center = CGPointMake(-1000, -1000);
return temp;
}
+(cpBody *)setupBody{
cpVect verts[]={cpv(-30,30), cpv(30, 30), cpv(30, -30), cpv(-30,-30)};
cpFloat block_moment = cpMomentForPoly(kSCrossMass, 4, verts, cpvzero);
return cpBodyNew(kSCrossMass, block_moment);
}
+(cpShape *)setupShape:(cpBody *)body inSpace:(cpSpace *) space{
cpVect verts1[]={cpv(-6,30), cpv(6, 30), cpv(6, -30), cpv(-6, -30)};
cpVect verts2[]={cpv(-30, 6), cpv(30, 6), cpv(30, -6), cpv(-30, -6)};
cpShape *shape = cpPolyShapeNew(body, 4, verts1, cpv(0,0));
shape->e = kSCrossElasticity;
shape->u = kSCrossFriction;
shape->collision_type = 0;
//return shape;
cpSpaceAddShape(space, shape);
shape = cpPolyShapeNew(body, 4, verts2, cpv(0,0));
shape->e = kSCrossElasticity;
shape->u = kSCrossFriction;
shape->collision_type = 0;
return shape;
}
Any idea's on how I could go about this would be greatly appreciated!