Cocos2d iphone 在iOS中,CCTouchStart不起作用

Cocos2d iphone 在iOS中,CCTouchStart不起作用,cocos2d-iphone,Cocos2d Iphone,问题在于 \u nextproject=[[CCSprite spriteWithFile:@“newarrow.png”]retain]; _nextproject.position=ccp(430190) 当我在init方法中初始化uu nextproject时,cctouchBegined方法不起作用。。 并通过输入\u nextproject=[[CCSprite spriteWithFile:@“newarrow.png”]retain]; _nextproject.position=

问题在于

\u nextproject=[[CCSprite spriteWithFile:@“newarrow.png”]retain]; _nextproject.position=ccp(430190)

当我在init方法中初始化uu nextproject时,cctouchBegined方法不起作用。。 并通过输入\u nextproject=[[CCSprite spriteWithFile:@“newarrow.png”]retain]; _nextproject.position=ccp(430190) 在CCTouch中,它开始在每次触摸执行时初始化。
有人帮忙吗

为同一层启用触摸

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {

    if (_nextProjectile != nil) return;

    CGPoint location = [touch locationInView:[touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];

    [[SimpleAudioEngine sharedEngine] playEffect:@"pew-pew-lei.caf"];

    CGSize winSize = [[CCDirector sharedDirector] winSize]; 

    CGRect rect = CGRectMake(imgArrow.position.x, imgArrow.position.y,imgArrow.contentSize.width, imgArrow.contentSize.height); 

    if(CGRectContainsPoint(rect, location))
    {
        **_nextProjectile = [[CCSprite spriteWithFile:@"newarrow.png"]retain];
        _nextProjectile.position = ccp(430,190);**

        [imgArrow runAction:[CCSequence actions:
                             [CCRotateTo actionWithDuration:0 angle:0],
                             [CCCallFunc actionWithTarget:self selector:@selector(finishShoot)],
                             nil]]; 

        [blankBow setVisible:true];
        [imgArrow setVisible:false];   
        [walkAnimFrames addObject:
         [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
          [NSString stringWithFormat:@"bow1.png", 0]]];

        [walkAnimFrames addObject:
         [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
          [NSString stringWithFormat:@"bow2.png", 1]]];

        [walkAnimFrames addObject:
         [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
          [NSString stringWithFormat:@"bow3.png", 2]]];

        walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.2f];

        self.walkAction = [CCRepeatForever actionWithAction:
                           [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];

        self.walkAction.tag = 1;
        [blankBow runAction:_walkAction];

        CCSprite *sprite = blankBow;

        CCCallBlock *block = [CCCallBlock actionWithBlock:^{
            [sprite stopActionByTag:1];
        }];
        CCDelayTime *time = [CCDelayTime actionWithDuration:0.3];
        [sprite runAction:[CCSequence actions:time, block, nil]];

        if(flagmultitouch == TRUE)
        {  
            id actionMove = [CCMoveTo actionWithDuration:1.5 
                                                position:ccp(-48,160)];
            id actionMoveDone = [CCCallFuncN actionWithTarget:self 
                                                     selector:@selector(spriteMoveFinished:)];
            [_nextProjectile runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];

            flagmultitouch = FALSE;  
        } 

        if(_nextProjectile !=nil)
            _nextProjectile.tag = 2;
    }
    else
    {

    }

    return YES;
}

将断点放在CCtouchStart的顶部,是否命中?上面的代码工作正常,但当我按两次对象时,对象\u nextproject出现两次..这意味着每次\u nextproject重新初始化..如果(\u nextproject!=nil)返回,请删除此行;通过删除if(_nextproject!=nil)返回;它第一次工作正常,但由于未捕获的异常“NSInternalInconsistencyException”,显示终止应用程序时出错,原因是:当我再次按下时,“参数必须为非零”。\u下一个项目是自动释放对象…不保留,请重试一次:
-(void)onEnter
{
    [super onEnter];

    self.touchEnabled = YES; //In Cocos2d 1.0: self.isTouchEnabled
}



- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: [touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];

}