cocos2d中的ccfollow操作

Sri*_*Sri 1 iphone tap cocos2d-iphone

ccfollow动作正确地跟随我的射弹.什么时候,双击识别.

看下面的代码.是错的.

这是我的代码: -

- (void)update:(ccTime)dt {
    if (numTaps==1 ) {
[self runAction:[CCFollow actionWithTarget:nextProjectile worldBoundary:CGRectMake(0,0,1050,350)]];
            }
}

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    numTaps = [[touches anyObject] tapCount];
 printf("Tapcount : %d",numTaps);
    if (numTaps ==1) {

    nextProjectile = [[CCSprite spriteWithFile:@"Weapon.png"] retain];
    nextProjectile.position =  ccp(nextprojectile .contentSize.width/2+65, nextprojectile.contentSize.height/2+70);
[nextProjectile runAction:[CCSequence actions: [here's my nextprojectile actions],nil]];
}
}
Run Code Online (Sandbox Code Playgroud)

看过上面的代码.你提出的一个问题.为什么在if条件中提到ccfollow动作.

答案在这里,通常,我在更新功能中提及它将无法正常工作,当我设置此条件时,如果条件在双击识别后工作.

如何纠正这个问题?

任何帮助将受到高度赞赏.

Sri*_*vas 6

没有更新,请尝试此编码

[self runAction:[CCFollow actionWithTarget:nextProjectile worldBoundary:CGRectMake(0,0,1050,350)]];
            }
Run Code Online (Sandbox Code Playgroud)

添加你的射弹时.像你的代码中的一些东西[self addchild: nextprojectile];