vendredi 24 avril 2015

AS3: Random spawn within a specific area

I am trying to figure out how to create a function which spawns "Orbs" within a specific area on the stage.

Basically, I have a stage with a size of 550 x 400 and inside the stage I have 5 rectangles which have fixed locations. Like this: My Stage

Now, I don't know what is the best way to tackle this.

-Spawn 1 orb at a time and write a function which checks if the orb has spawned inside a rectangle, delete the orb and spawn another one until it spawns outside the rectangle?

-Or create invisible objects around all the rectangles to spawn the orbs within them...

I am literally clueless and this is the first time I'm doing anything on flash/as3.

Any help is appreciated, thanks.




Aucun commentaire:

Enregistrer un commentaire