Question

ccfollow actions is following my projectile correctly. when, double tap recognised.

see the below code. were am mistaken.

here is my code:-

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

after seen the above code. a question raised by you. why am mentioning the ccfollow action in if condition.

answer is here, ordinarily, am mention in update function it will not works, when i set this if condition it works after double tap recognised.

how to rectify this issue?

any help would be highly appreciated.

Was it helpful?

Solution

not in update, try this coding in

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

when adding your projectile. some thing like in your code [self addchild: nextprojectile];

OTHER TIPS

What is the problem/issue - you mention double taps, but then code is "numTaps == 1".

Are you saying it only works for double taps, but you want it to work for single taps?

What is working? What is not working?

Have you tried the cocos2d forums?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top