how to stop the array of sprite in cocos2d?

Posted by prakash s on Game Development See other posts from Game Development or by prakash s
Published on 2012-10-08T08:59:17Z Indexed on 2012/10/09 9:55 UTC
Read the original article Hit count: 303

Filed under:

I am devoloping the bubble shooter game in cocos2d how to stop the sprite movement at the center of the game scene in my game bec i want to shoot the bubble after stopping the movenent at certain position here is my code

-(void)addTarget {

CGSize winSize = [[CCDirector sharedDirector] winSize];


NSMutableArray * movableSprites  = [[NSMutableArray alloc] init];
NSArray *images = [NSArray arrayWithObjects:@"1.png", @"2.png", @"3.png", @"4.png",@"5.png",  @"6.png", @"7.png",@"8.png" ,nil];       


    for(int i = 0; i < images.count; ++i) {




        int index = (arc4random() % 8)+1;
        NSString *image = [NSString stringWithFormat:@"%d.png", index];
        CCSprite*target = [CCSprite spriteWithFile:image];










    // generate random number based on size of array (array size is larger than 10)




    float offsetFraction = ((float)(i+1))/(images.count+1);
    //target.position = ccp(winSize.width*offsetFraction, winSize.height/2);
    target.position = ccp(350*offsetFraction, 460);



    [self addChild:target];
    [movableSprites addObject:target];














    id actionMove = [CCMoveTo actionWithDuration:10 position:ccp(350*offsetFraction, 100)]; 
            id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
    [target runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];








}   


here bubbles are moving from top to bottom but after 5 rows my bubble movement should be stop so please help me to get that logic

© Game Development or respective owner

Related posts about cocos2d