iphone - "Layer#ccTouchBegan override me" Error -


can please tell me why isn't working? keep getting error:

terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'layer#cctouchbegan override me'

when take out

[[ccdirector shareddirector].touchdispatcher addtargeteddelegate:self priority:0 swallowstouches:yes];

it doesn't crash, doesn't work not answer.

// import interfaces #import "helloworldlayer.h" #import "cctouchdispatcher.h"  ccsprite *man; ccsprite *death;  // needed obtain navigation controller #import "appdelegate.h"  #pragma mark - helloworldlayer  // helloworldlayer implementation @implementation helloworldlayer   // helper class method creates scene helloworldlayer child. +(ccscene *) scene { // 'scene' autorelease object. ccscene *scene = [ccscene node];  // 'layer' autorelease object. helloworldlayer *layer = [helloworldlayer node];  // add layer child scene [scene addchild: layer];  // return scene return scene; }  // on "init" need initialize instance -(id) init { // call "super" init // apple recommends re-assign "self" "super's" return value if( (self=[super init]) ) {      man = [ccsprite spritewithfile:@"man.png"];     man.position = ccp(150,150);     [self addchild: man];     death = [ccsprite spritewithfile:@"death.png"];     death.position = ccp(100,100);     [self addchild: death];      [self schedule:@selector(calleveryframe:)];      [[ccdirector shareddirector].touchdispatcher addtargeteddelegate:self priority:0    swallowstouches:yes];  } return self; }  // on "dealloc" need release retained objects - (void) dealloc { // in case have dealloc, in method // in particular example nothing needs released. // cocos2d automatically release children (label)  // don't forget call "super dealloc" [super dealloc]; }  -(void) calleveryframe:(cctime)dt{  man.position = ccp(man.position.x +250*dt, man.position.y); if (man.position.x > 480 + 64) {     man.position =ccp(-64,man.position.y); } death.position = ccp(death.position.x, death.position.y +100*dt); if (death.position.y > 300+64){     death.position =ccp(death.position.x,-64);    }  }  -(bool)cctouchbegan:(uitouch *)touch withevent:(uievent *)event{ return yes; }    -(void)cctouchended:(uitouch *)touch withevent:(uievent *)event{     cgpoint location = [touch locationinview: [touch view]];     cgpoint convertedlocation = [[ccdirector shareddirector]converttogl:location];      [man stopallactions];     [man runaction:[ccmoveto actionwithduration:1 position:convertedlocation]]; }   @end 

you didn't implement cctouchbegan:withevent: method in class.

variable, class, method etc names in objective c case sensitive. @ code:

-(bool)cctouchbegan:(uitouch *)touch withevent:(uievent *)event{ return yes; }

Comments