I am new to ObjectiveC and I have following inheritance.
@interface CGameEntity : NSObject {
b2Body *entityBody;
}
@property(nonatomic,retain) CCSprite *entitySprite;
-(id)initEntity:(CCNode*)parentNode :(b2World*)world;
@end
implementation :
@implementation CGameEntity
@synthesize entitySprite=entitySprite;
.
.
.
@end
And extended class is as follows :
@interface CPlanet : CGameEntity {
}
@end
implementation is as follows:
@implementation CPlanet
-(id)initEntity:(CCNode*)parentNode :(b2World*)world
{
if((self = [super init]))
{
//cannot access "entitySprite" ????
entitySprite=[CCSprite spriteWithFile:@"planet.png"];
}
return self;
}
@end
In the extended class I cannot access the property “entitySprite”.
How can I access properties of the base class ?
Thank you
First of all, replace …
By …
Then, replace this line …
By this …
This will work =)!