Page 1 of 1

setSpriteZPos() - gives error when using 0/1

Posted: Mon Sep 25, 2017 10:59 pm
by peceha
Hi,
setSpriteZPos() throws an error:
Wrong usage/parameters for this command!
Read the documentation!
whenever I'm trying to bring to front (0) the sprite which is already in front or moving to the back (1) when the sprite is already at the back.

For example:

Code: Select all

SetFillStyle(#FILLCOLOR)

CreateBrush(0,100,100,#WHITE)
CreateSprite(0,#BRUSH,0)
DisplaySprite(0,0,0)

CreateBrush(1,100,100,#RED)
CreateSprite(1,#BRUSH,1)
DisplaySprite(1,50,50)

SetSpriteZPos(0,1) ; this line produces error msg. Changing to (1,0) gives an error as well

WaitKeyDown("any")

Re: setSpriteZPos() - gives error when using 0/1

Posted: Wed Sep 27, 2017 7:35 pm
by airsoftsoftwair
Well, yeah, the answer is already in your question. You're trying to bring a sprite to front which is at the front already and you're trying to bring a sprite to back which is at the back already. Of course SetSpriteZPos() fails then... it can't do anything that's already been done.

Re: setSpriteZPos() - gives error when using 0/1

Posted: Wed Sep 27, 2017 7:56 pm
by peceha
But is the error message necessary in that case ? I do not want my program to be stopped because of something that is ... not an error (in my opinion) ;)

Thanks

Re: setSpriteZPos() - gives error when using 0/1

Posted: Wed Sep 27, 2017 8:21 pm
by airsoftsoftwair
Then just use:

Code: Select all

ExitOnError(False)
SetSpriteZPos(...)
ExitOnError(True)

Re: setSpriteZPos() - gives error when using 0/1

Posted: Wed Sep 27, 2017 8:43 pm
by peceha
Thanks. Didn't think of it.

Re: setSpriteZPos() - gives error when using 0/1

Posted: Thu Jul 13, 2023 12:34 am
by marko
I ran into this issue as well, it caused some major headach :S...

Ah, now I know, thanks both