开发者

How to make UIView Objects spawn randomly

开发者 https://www.devze.com 2023-03-14 10:32 出处:网络
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 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...

  • Make UIView Objects spawn randomly off screen and come into view
  • Make the UIView Objects move about randomly
  • Make the UIView Objects spawn x amount of times over a given time
  • Make some UIView Objects stay in view while others travel outside the screen view and disappear

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消