1

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]];
}
}

看到上面的代码后。你提出的一个问题。为什么在 if 条件下提到 ccfollow 操作。

答案就在这里,通常,我在更新功能中提到它不起作用,当我设置这个如果条件它在双击识别后起作用。

如何纠正这个问题?

任何帮助将不胜感激。

4

2 回答 2

6

没有更新,试试这个编码

[self runAction:[CCFollow actionWithTarget:nextProjectile worldBoundary:CGRectMake(0,0,1050,350)]];
            }

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

于 2011-01-03T06:55:18.793 回答
0

什么是问题/问题 - 你提到双击,但代码是“numTaps == 1”。

你是说它只适用于双击,但你希望它适用于单击?

什么在起作用?什么不工作?

你试过cocos2d 论坛吗?

于 2010-12-31T13:54:56.410 回答