I have class called "HelloWorld.m" and another class called "Person.m". I have declared Person instance in the HelloWorld.m class as follows:
Person *person;
Now, when the user touches the screen I fire the following method:
[person foo];
But I get the error saying invalid selector sent.
NOTE: Person class inherits from the CCSprite class. What am I doing wrong?
Person.h:
-(void) foo;
Person.m:
-(void) foo
{
NSLog(@"foo called!");
}
UPDATE 1: In the HelloWorld.h and HelloWorld.m I have declarated person as a property. Here is the call to the person.foo method.
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.person foo];
}
HelloWorld.h:
// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"
#import "Person.h"
// Importing Chipmunk headers
#import "chipmunk.h"
// HelloWorld Layer
@interface HelloWorld : CCLayer
{
cpSpace *space;
Person *person;
}
// returns a Scene that contains the HelloWorld as the only child
+(id) scene;
-(void) step: (ccTime) dt;
-(void) addNewSpriteX:(float)x y:(float)y;
@property (nonatomic,retain) Person *person;
@end