Spawn Rule: How to spawn everywhere except a certain area???
Games4life
Member, PRO Posts: 279
I am currently creating another game that I am wondering how to spawn enemies everywhere on the map except a certain "safe zone". Anyone know how to do this?
Thanks
~G4L
Comments
I think I'd try spawning everywhere on your map and then add an invisible actor to act as the safe zone. Then create a rule in the enemy that if it touches the safe zone actor it is destroyed. So if that enemy were to spawn in the safe zone it would be immediately destroyed.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thanks i'll try that!
Something to keep in mind with what @jamie_c said, it's possible that using that method you can see a flick for one frame of the actor existing before its destroyed. A way to fix that is to make sure your destroy function is in the top rule within the actor. Another way is to make your actor invisible by turning off visibility or making the alpha 0, then having the actor become visible if it hasn't been destroyed by the big square. I do this with randomly spawned coins.
Vote for Nearest Neighbor Scaling option in gamesalad! Let's make our games look truly stunning!
Can you give me a sample piece of code to give ideas on how to start?
Thanks!!
Something like this:
Change Attribute: self.Alpha = 0 (add this as your first bit of code on the actor)
Rule: if collides with invisible actor (whatever you call this invisible actor):
... Destroy
Otherwise
... Change Attribute: self.Alpha = 1
And then all of your existing code below
Keep in mind that if the actor ever moves onto this invisible actor at a later time it will be destroyed. If your actors move and you don't want that to happen then something like this should work:
Change Attribute: self.Alpha = 0 (add this as your first bit of code on the actor)
Change Attribute: self.justSpawned = true
Timer: After 1 second
... Change Attribute: self.justSpawned = false
Rule: if collides with invisible actor and self.justSpawned = true:
... Destroy
Otherwise
... Change Attribute: self.Alpha = 1