views:

28

answers:

0

I am using cocos2d to develop a game. I used a TouchableSprite as follow:

http://www.cocos2d-iphone.org/forum/topic/3196

So, I create a new class which is a sub class of TouchableSprite. But it have some problems.... See the code first:

#import <Foundation/Foundation.h>
#import "TouchableSprite.h";

@interface MySprite : TouchableSprite {
}

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event;
@end

and the .m:

#import "MySprite.h"
@implementation MySprite

-(id) init
{
    if((self = [super init])){

    }

    return self;
}

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
    [super ccTouchBegan:touch withEvent:event];

    NSLog(@"called from my sprite");

    return YES;

}

And I can display the "called from my sprite", but when I click again, it displays something like this:

 *** Assertion failure in -[BrickSprite ccTouchEnded:withEvent:], /... ../TouchableSprite.m:83


 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Paddle - Unexpected state!'
*** Call stack at first throw:

What happen? Why I can't override the ccTouchBegan method? thank you.