0
-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
 {

     _nextProjectile = [[CCSprite spriteWithFile:@"arrow.png"]retain];
     _nextProjectile.position = imgArrow.position;

        [imgArrow runAction:[CCSequence actions:
                            [CCRotateTo actionWithDuration:rotateDuration angle:cocosAngle],
                            [CCCallFunc actionWithTarget:self selector:@selector(finishShoot)],
                            nil]];
    //Some code 

    }

- (void)finishShoot {

    // Ok to add now - we've finished rotation!

    [self addChild:_nextProjectile];
    [_projectiles addObject:_nextProjectile];

    // Release
    [_nextProjectile release];
    _nextProjectile = nil;
}

弓を 2 回クリックすると、矢印が重なります。

何か助けて?!ここに画像の説明を入力

4

2 に答える 2

0

追加する前に、このコードを試してください。矢印を削除しました (構文エラーがある場合は修正します)。

-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
 {
 [self removeChild:[self childWithTag:101]];
 _nextProjectile = [[CCSprite spriteWithFile:@"arrow.png"]retain];
 _nextProjectile.tag = 101;
 _nextProjectile.position = imgArrow.position;

    [imgArrow runAction:[CCSequence actions:
                        [CCRotateTo actionWithDuration:rotateDuration angle:cocosAngle],
                        [CCCallFunc actionWithTarget:self selector:@selector(finishShoot)],
                        nil]];
//Some code 

}
于 2013-04-22T19:04:25.727 に答える