Iphone &引用;图层“CCI开始覆盖我”;错误

Iphone &引用;图层“CCI开始覆盖我”;错误,iphone,objective-c,overriding,Iphone,Objective C,Overriding,有人能告诉我为什么这不起作用吗? 我不断地发现这个错误: 由于未捕获异常“NSInternalInconsistencyException”而终止应用程序,原因是:“Layer#CCTouchBegind override me” 当我出去的时候 [[CCDirector sharedDirector].touchDispatcher AddTargetedElegate:自优先级:0燕子接触:是] 它没有崩溃,但也不起作用,这肯定不是答案 // Import the interfaces #i

有人能告诉我为什么这不起作用吗? 我不断地发现这个错误:

由于未捕获异常“NSInternalInconsistencyException”而终止应用程序,原因是:“Layer#CCTouchBegind override me”

当我出去的时候

[[CCDirector sharedDirector].touchDispatcher AddTargetedElegate:自优先级:0燕子接触:是]

它没有崩溃,但也不起作用,这肯定不是答案

// Import the interfaces
#import "HelloWorldLayer.h"
#import "CCTouchDispatcher.h"

CCSprite *man;
CCSprite *death;

// Needed to obtain the Navigation Controller
#import "AppDelegate.h"

#pragma mark - HelloWorldLayer

// HelloWorldLayer implementation
@implementation HelloWorldLayer


// Helper class method that creates a Scene with the HelloWorldLayer as the only child.
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];

// 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];

// add layer as a child to scene
[scene addChild: layer];

// return the scene
return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "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" you need to release all your retained objects
- (void) dealloc
{
// in case you have something to dealloc, do it in this method
// in this particular example nothing needs to be released.
// cocos2d will automatically release all the children (Label)

// don't forget to 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

您没有在类中实现
ccTouchBegind:withEvent:
方法

目标C中的变量、类、方法等名称区分大小写。现在仔细看看 您的代码:

-(BOOL)CCTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{ return YES; } -(BOOL)cctouch开始:(UITouch*)触摸事件:(UIEvent*)事件{ 返回YES; }