how to give action to the CCArray which contain bubbles(sprites)
- by prakash s
I am making bubbles shooter game in cocos2d
I have taken one array in that i have inserted number of different color bubbles and i showing on my game scene also ,
but if give some move action to that array ,it moving down but it displaying all the bubbles at one position and automatically destroying , what is the main reason behind this please help me
here is my code:
-(void)addTarget {
CGSize winSize = [[CCDirector sharedDirector] winSize];
//CCSprite *target = [CCSprite spriteWithFile:@"3.png" rect:CGRectMake(0, 0, 256, 256)];
NSMutableArray * movableSprites = [[NSMutableArray alloc] init];
NSArray *images = [NSArray arrayWithObjects:@"1.png", @"2.png", @"3.png", @"4.png",@"5.png",@"1.png",@"5.png", @"3.png", nil];
for(int i = 0; i < images.count; ++i) {
NSString *image = [images objectAtIndex:i];
// generate random number based on size of array (array size is larger than 10)
CCSprite*target = [CCSprite spriteWithFile:image];
float offsetFraction = ((float)(i+1))/(images.count+1);
//target.position = ccp(winSize.width*offsetFraction, winSize.height/2);
target.position = ccp(350*offsetFraction, 460);
// [[CCActionManager sharedManager ] pauseAllActionsForTarget:target ] ;
[self addChild:target];
[movableSprites addObject:target];
//[target runAction:[CCMoveTo actionWithDuration:20.0 position:ccp(0,0)]];
id actionMove = [CCMoveTo actionWithDuration:10 position:ccp(winSize.width/2,winSize. height/2)];
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
[target runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];
}
}
after the move at certain position
i want to display all the bubbles in centre of my window