0
// PROG 1做[sprite stopActionByTag:kTag]; CCAction和CCSequence的工作方式不同嗎?
-(void)gameLogic:(ccTime)dt
{
id actionMove = [CCMoveTo actionWithDuration:1.0 position:ccp(windowSize.width/2-400, actualY)];
[actionMove setTag:6];
[self schedule:@selector(update:)];
[hitBullet runAction:actionMove];
}
-(void)update:(ccTime)dt
{
if ((CGRectIntersectsRect(hitRect, playerRect)))
{
[[[self getActionByTag:6] retain] autorelease];
[hitBullet stopActionByTag: 6];
}
}
// PROG 2
-(void)gameLogic:(ccTime)dt
{
id actionMove = [CCMoveTo actionWithDuration:1.0 position:ccp(windowSize.width/2-400, actualY)];
id hitBulletAction = [CCSequence actionWithDuration:(intervalforEnemyshoot)];
id hitBulletSeq = [CCSequence actions: hitBulletAction, actionMove, nil];
[hitBulletSeq setTag:5];
[self schedule:@selector(update:)];
[hitBullet runAction:hitBulletSeq];
}
-(void)update:(ccTime)dt
{
if ((CGRectIntersectsRect(hitRect, playerRect)))
{
[[[self getActionByTag:5] retain] autorelease];
[hitBullet stopActionByTag: 5];
}
}
雖然PROG1工作PROG2不工作?我認爲兩者都是一樣的。但爲什麼兩個stopActions在兩個prog1和prog2中的工作方式不同?我的意思是行動在prog1停止,但行動不是在prog2停止? 謝謝你。
Nash, 我正在使用cocos2d_0.99.0版本。在我的代碼中是否有任何錯誤?但是,在Prog1中,操作正在停止,並且在prog2中它不會停止。所以我試過 [self removeChildByTag:cleanUp:];這是工作。但是,爲什麼不removeActionByTag:。我會做你說的並且調試它。 謝謝。 – 2010-04-13 12:59:20