Screen Shot 2015-04-21 at 9.29.18 AM.jpg
This should work
thank you my friends...
thank you JHale, this is what I'm looking for. I dont want to destroy objects and create everytime.
What means "EnemyDistance" ?
Just to point out that my previous example was tailored on destroying,I dont want to destroy objects and create everytime.
but you could just substitute "destroy" with "make invisible"
and obviously revert it to "reappear"...
The subtle meaning of the example was to demonstrate that looping is unnecessary in this situation
although I'm a huge fan of the always-foreach combination..
thanks schrodinger. The list object it's just to manage, right? I dont need it to make you example works. Or i'm wrong?
it's just to show what happens behind the scene
(since when objects get out of the screen you can't tell if-and which- is invisible!)
and tell us he is doing a one-a-time job, and not all together.
You can get rid of that
Thanks again friend.
EnemyDistance is a global value that I created so instead of re typing the value if I want to change it I just change the global value I used.
Quick tip::: try to use alt values and strings as much as you can so later if you need to change many events you can just change the alt value and it will effect every event that it uses.
What is the performance impact of using for each loops in comparison to using no for each loops?
If for each loops have a slight impact you could try using behaviors instead. Everyone seems to overlook behaviors, but I think most people just don't comprehend how useful they can actually be, even if you can't reference groups in them.
Just paste your code into a behavior and copy&paste that behavior to ALL objects you need to disappear/reappear. You avoid for-each loops this way and get the same effect.