how to give action to the CCArray which contain bubbles(sprites)
Posted
by
prakash s
on Game Development
See other posts from Game Development
or by prakash s
Published on 2012-10-05T12:30:05Z
Indexed on
2012/10/05
15:56 UTC
Read the original article
Hit count: 299
cocos2d
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
© Game Development or respective owner