is there any example that shows a asteroid like game with unlimited enemy/asteroids spawning?
How can I do this with cocos2d and box2d?
PS: They should come from all directions…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is so general that you seem like just crawling into the dark.
What you want is to set a maximum amount of enemies and then randomly (possibly biased by the difference between maximum enemies and current enemies, so that if there are less enemies the chance to spawn a new one is higher) you spawn them.
You can do it in
-(void)update:(ccTime)dtmethod which is automatically called by cocos2d life cycle on every repaint of the whole display. You can enable this automatic scheduling by calling[self scheduleUpdate]in the init method of yourCCLayersubclass.