Hi All,
I am creating a game something like Plant Vs Zombies, with multiple sprites (the plants). Then,
I want them to auto-fire a bullet into incoming enemy (the zombies).
What is the best way of doing this?
I am not really good at object oriented, I tried the following (just pseudo to illustrate my approach):
in my init method of my code:
// schedule a repeating game loop
[self schedule:@selector(myGameLoop

];
in myGameLoop method:
for (CCSprite thePlantSprite in thePlantSpriteArray) {
...(retrieve thePlantSprite position x and y)
[self fireBullet]; // call this method to fire a bullet from current sprite
}
I have logic problems:
1. this myGameLoop will get executed many times in a second and caused hundreds of bullets shot.
2. how can I limit to say a bullet can be shot by any sprite in every 2 seconds.
Thanks.