Search code examples
objective-cxcode4chipmunk

chipmunk cpVect type in method argument incompatble


Im trying to pass an array cpVect in a method arguments like this;

cpVect v1[] = {
        cpv(-31.5f/2.0, 70.5f/2.0),
        cpv(43.5f/2.0, 65.5f/2.0),
        cpv(34.5f/2.0, -69.5f/2.0),
        cpv(-52.5f/2.0, -69.5f/2.0)
    };

Rocks *rock = [[Rocks alloc] initWithSpace:space location:ccp(200, 700) filename:@"2_piedra1.png" verts:v1];

and the method:

- (Rocks *)initWithSpace:(cpSpace *)theSpace location:(CGPoint)location filename:(NSString *)filename verts:(cpVect)verts;

but fails with the type

thanks for the help


Solution

  • Your method should look like this:

    • (Rocks *)initWithSpace:(cpSpace *)theSpace location:(CGPoint)location filename:(NSString *)filename verts:(cpVect *)verts;

    Note the '*' after cpVect on the last argument. You are passing an array (pointer) of cpVect values, not just a single one.