Page 1 of 1
Why is this not working? (possibly bug)
Posted: Sat Aug 11, 2012 12:47 pm
by Bugala
Code: Select all
@SCREEN {Mode = "FakeFullScreen"}
@DISPLAY {Width = 1920, Height = 1080, Borderless = True, ScaleMode = #SCALEMODE_AUTO, FitScale=True}
EnableLayers
CreateBrush(1, 50, 50, $CCCC55)
InsertLayer(1, #BRUSH, 1, 885, 650)
InsertLayer(2, #BRUSH, 1, 935, 650)
InsertLayer(3, #BRUSH, 1, 985, 650)
InsertLayer(4, #BRUSH, 1, 935, 600)
InsertLayer(5, #BRUSH, 1, 935, 450)
For n=1 To 5
DebugPrint(n)
RemoveLayer(n)
Next
When i try to run, it fails at point it tries to remove layer number 4. Why?
Is this a bug or is it supposed to work this way?
Re: Why is this not working? (possibly bug)
Posted: Sat Aug 11, 2012 4:25 pm
by Allanon
If you have a look at the layer introduction you can see that the layer id is dinamically changed when you use the RemoveLayer() function, see below:
layer id 1 -> obj a
layer id 2 -> obj b
layer id 3 -> obj c
if you remove layer 2 with RemoveLayer you will have
layer id 1 -> obj a
layer id 2 -> obj c
So, if you want that your code will work you have at least use the for .. next inverted with:
Code: Select all
For n=5 To 1 step -1
DebugPrint(n)
RemoveLayer(n)
Next
Or alternatively, you should use layer names to be sure that you are deleting exactly want you want.
P.S.: code not tried
Re: Why is this not working? (possibly bug)
Posted: Sat Aug 11, 2012 7:26 pm
by Bugala
Ah, okay, thanks Allan!
That explains it.
I normally use layernames and this was just exceptional that i decided it would be easier to use layerids instead so hence it didnt come to my mind that it would keep reordering the queue.