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

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
PEB
Posts: 588
Joined: Sun Feb 21, 2010 1:28 am

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

Post by PEB »

You can use this instead:
If LayerExists("enemy"..n)=True Then RemoveLayer("enemy"..n)
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

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

Post by Bugala »

Oh yeah, I had completely forgot that command existed. Thanks a dozen PEB! That solved my problem.
Post Reply