views:

111

answers:

1

I am trying to have AtlasSprite as a parent class but it's giving me errors on propreties. Like it can't seem to find them: Here's the code extract.

interface:

@interface Glyph : AtlasSprite{
  float eyelevel;
}
@property (readwrite,assign) float eyelevel;
-(id) initWithMgr:(id) mgr;

implementation:

@implementation Glyph

@synthesize eyelevel;
-(id) init {
 if( (self=[super init] )) {
  eyelevel = 0;
 }
 return self;
}

-(id) initWithMgr:(id) mgr{
    if( (self=[super init] )) {
       [self init];
       self = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 119, 45) spriteManager: mgr];
    }
    return self;
}

here are the calls to this class:

AtlasSpriteManager *mgr = AtlasSpriteManager spriteManagerWithFile:@"atlas_glyph.png" capacity:3];
Glyph *glyph = [[Glyph alloc] initWithMgr:mgr];
[glyph setEyelevel:0];

It keeps crashing for me when it hits [glyph setEyelevel:0]; , saying it doesn't recognize the selector to the instance. Any help?

A: 

Your @synthesize statement does not match your @property.

@property (readwrite,assign) float currentEyeLvlY;

But you synthesize the setter with:

@synthesize eyelevel;

You need these variables to match, or explicitly define the relationship in your @synthesize like so:

@synthesize currentEyeLvlY = eyelevel;
guest