objective-c spawn many monsters
I made a little iPhone game but now I wanted to make multiple monsters to spawn. So I have one UIImageView called enemy that spawns at beginning of the game. But I want it to spawn many more monsters until开发者_如何学Python I say it needs to stop spawning them. I know how to get random locations. I don't want to add like 20 other enemy's and 20 image views and give them all the same function i jus twang to declare one image view called enemy but that image spawns many times.
Any help? Thanks!
Each enemy will likely need its own coordinates, position, hitpoints, spellpoints, etc. So the obvious solution would be to have something like a MonsterTracker class that has an array of Monster objects that you expand to the number of instances you need.
Create a monster factory using the factory pattern. Here's an obj-c example.
精彩评论