Hi,
Just getting into Cocos2d and game development in general and i'm having a bit of trouble using a singleton directly from the ccTouchesEnded method. Below is the code i'm using to test this.
-(id) init
{
if( (self=[super init])) {
self.isTouchEnabled = YES;
// This works fine and can be called any number of times
[[characterInformation sharedCharacterInformation] addXP:[NSNumber numberWithInt:100]];
[[characterInformation sharedCharacterInformation] addXP:[NSNumber numberWithInt:100]];
[[characterInformation sharedCharacterInformation] addXP:[NSNumber numberWithInt:100]];
[[characterInformation sharedCharacterInformation] addXP:[NSNumber numberWithInt:100]];
}
return self;
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// This doesn't work and crashes the application
[[characterInformation sharedCharacterInformation] addXP:[NSNumber numberWithInt:100]];
}
I'm not entirely sure why it's crashing on touching the screen as it doesn't from the init method (or any other method I create) can anyone shed any light on it?
Thanks in advance