Idratherfly2000
Idratherfly2000

Reputation: 21

How to make UIView Objects spawn randomly

I am trying to figure out how to make UIView Objects spawn from off screen from random locations and come onto screen (kind of like Asteroids the old game).

I want the amount to vary over time, starting off with only one object that spawns and then over a certain amount of time another one spawns (so on and so on) I want some of the randomly spawned objects to stay on screen the entire time and travel in a random direction when the object contacts the side of the screen. I also want other objects to just pass by the screen once from random locations.

Broken down for easier reading...

In Laymans Terms: I am creating a game like Asteroids and need to figure out how to spawn the "Asteroids"

Any help at all on the coding for any of the above would be more than helpful. If you need any more information please let me know

Upvotes: 0

Views: 198

Answers (1)

Caleb
Caleb

Reputation: 125007

Don't try to make the views create themselves -- that's not going to work. Instead, you need some object that manages the game state, basically a data model. That object will keep track of the objects that are already in the game, figure out when objects have been destroyed, and create more as needed.

Upvotes: 1

Related Questions