Page 1 of 1

Is it safe to use ExitOnError(false) with Removelayer()?

Posted: Sun Apr 28, 2013 11:14 am
by Bugala
When level ends, or I move from game to title menu or whatever, I am in need of removing lot of layers.

Simplest way would be to use something like:

Code: Select all

ExitOnError(false)

for n = 1 to 100
removelayer("enemy"..n)
next n

ExitOnError(true)
Point is that I know some of the layers dont exist anymore, and hence I would be turning Exit on Error off, or otherwise program would exit.

But is this safe way to do it? or might this cause some trouble to be using ExitOnError(false) in connection with removelayer when many of the layers to be removed wont be existing?

Re: Is it safe to use ExitOnError(false) with Removelayer()?

Posted: Sun Apr 28, 2013 1:09 pm
by PEB
You can use this instead:
If LayerExists("enemy"..n)=True Then RemoveLayer("enemy"..n)

Re: Is it safe to use ExitOnError(false) with Removelayer()?

Posted: Sun Apr 28, 2013 5:26 pm
by Bugala
Oh yeah, I had completely forgot that command existed. Thanks a dozen PEB! That solved my problem.