I am building a game for iphone, I am new to game devolopment and somewhat new to the language. I have balls that fall from the top of the screen to the bottom and the player is supposed to try and catch them. The problem is, I add the new sprites with an "addnewBallSprite" method, and later act on the position in my UpdateEveryFrame method. But if there is still a ball on the screen when a new ball is created the old ball stops moving. Is there a way I can make my change in position command control all instances of the ball sprite??? Please explain in detail. Below is my addNewBall method:
-(void) addNewBall {
int RandomXPosition = (arc4random() % 240) + 40;
int RandomBallSprite = (arc4random() % 5);
NSString *BallFileString = @"OrangeBall.png";
switch (arc4random() % 5) {
case 1:
BallFileString = @"OrangeBall.png";
break;
case 2:
BallFileString = @"GreenBall.png";
break;
case 3:
BallFileString = @"YellowBall.png";
break;
case 4:
BallFileString = @"PinkBall.png";
break;
case 0:
BallFileString = @"BlueBall.png";
break;
}
Ball = [CCSprite spriteWithFile:BallFileString];
Ball.position = ccp(RandomXPosition, 520);
[self addChild:Ball z:1];
}