How do I handle the situation of an enemy spawn place being visible on a screen in a scrolling shooter? The tutorials I have seen are about setting all the enemies on a whole map only. But it is not appropriate if the map is huge.
|
|
If I am interpreting your question correctly, you do not want your enemies to have already spawned because your “world” is so large. As such, you want them to spawn only when the player is approaching the spawn point. If your scroller moves at a constant pace, then you could spawn your enemies after a specific time interval. If your scroller does not move at a constant pace, or if it is multi-directional, then you need something to trigger spawning. Checking the distance between the player and the spawn point would work, assuming you don’t have thousands of spawn points. Or if they cross over a “trigger” object in your world, that could be used to spawn your enemies. There are many approaches you could take. Depending on the number of enemies and the size of your world, you could easily have your enemies already spawned, but inactive. Generally, just having them in existence is not nearly as CPU intensive as updating them within your game loop, but there are exceptions. So, you can have them already spawned, but they don’t come to life until certain conditions are met, such as the distance between the player and the enemy, or if the player touches or shoots the enemy, etc. Since you tagged your question with Cocos2d, take a look at this tutorial: http://www.packtpub.com/article/cocos2d-iphone-surfing-through-scenes It will pretty much guide you through the entire process of creating a game from start to finish. The game is simple, but you will learn the basics and some handy techniques. Also look here for many helpful tutorials. http://www.raywenderlich.com/tutorials I hope this helps. |
|||||||||
|