You certainly do not want a timer firing for EVERY bullet, asteroid, explosion animation etc., this would be horrendous.
Most games are based on what is termed a finite-state-machine. This is in essence a method that keeps track of the game state (i.e. PLAYING, END_GAME, WAITING_FOR_OTHERPLAYERS) and makes decisions based on that. This method would get called over and over again via ONE timer, much like you have done for the bullet. I would suggest setting up your game like that. Now about those bullets, when the player hits the fire button, add another bullet to an array of things-that-need-to-adjust-themselves-over-time. Then each time through the game loop, when the state dictates, iterate through them and tell them to "updateYourself". This would also be where you would do your collision detection and start explosion animations, remove objects that have gone off-screen etc.
Hope that helps,
Kenny
Update: some pseudo code (i.e. will not compile) that should explain things better. Note that I always like to pass the game time around so that an object knows nothing of the ACTUAL time, this is good practice as it not only allows for reanimating of a game session, great for debugging and sometimes can make for a neat feature, it also means all objects get the SAME time, not milliseconds different than the first object based on where it is in the array. HOT TIP of the DAY!! Woo hoo!!
// implementation in MainGame class
// After application has had its lunch....
- (void) applicationDidFinishLunching {
gameTimer = [NSTimer scheduledTimerWithTimeInterval:GAMETIME_INTERVAL target:self selector:@selector(myGameLoop) userInfo:nil repeats:TRUE];
}
- (void) startGame {
gameState = PLAYING;
// And most likely a whole bunch of other stuff
}
NSMutableArray * mTransientObjects;
- (void) fireButtonPressed:(float) atY andTime:(NSTimeInterval) fireTime {
// I will assume only a "Y" variable for this game, Galaga style.
Bullet * aBullet = [[Bullet alloc] initWithY:atY atTime:fireTime];
[mTransientObjects addObject:aBullet];
[aBullet release];
}
// myGameLoop is called via the timer above firing at whatever interval makes sense for your game
- (void) myGameLoop {
switch (gameState) {
case PLAYING:
for (nextObject in mTransientObjects)
[nextObject updateYourself:gameTime];
// Now check for dead object, add explosions to mTransientObjects
// Remove dead things, add anything new etc.
etc.
}
// implementation in Bullet subclass
// Bullet is SubClass of your overall Sprite class
- (void) updateYourself:(NSTimerInterval) timeInterval {
// Do any movement, change of animation frame, start sound....etc. etc.
}