"Expected specifier-quantifier-list before b2Body" error in XCode

Posted by Zeophlite on Stack Overflow See other posts from Stack Overflow or by Zeophlite
Published on 2010-12-29T09:01:59Z Indexed on 2010/12/31 1:54 UTC
Read the original article Hit count: 303

I'm trying to derive class from CCSprite to store the sprites reference to its corresponding b2Body, but I've get the following errors (comments in Code)

BoxSprite.h

#import <Foundation/Foundation.h>
#import "Box2D.h"
#import "cocos2d.h"

@interface BoxSprite : CCSprite {
    b2Body* bod; // Expected specifier-quantifier-list before b2Body
}

@property (nonatomic, retain) b2Body* bod; // Expected specifier-quantifier-list before b2Body

@end // Property 'bod' with 'retain' attribute must be of object type

BoxSprite.m

#import "BoxSprite.h"

@implementation BoxSprite

@synthesize bod; // No declaration of property 'bod' found in the interface

- (void) dealloc
{
    [bod release]; // 'bod' undeclared
    [super dealloc];
}

@end

I was hoping to create the sprite and assign the body with:

BoxSprite *sprite = [BoxSprite spriteWithBatchNode:batch rect:CGRectMake(32 * idx,32 * idy,32,32)];
...
sprite->bod = body; // Instance variable 'bod' is declared protected

Then access the b2Body by:

if ([node isKindOfClass:[BoxSprite class]]) {
    BoxSprite *spr = (BoxSprite*)node;
    b2Body *body = spr->bod; // Instance variable 'bod' is declared protected
    ...
}

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about box2d-iphone