Game Lab, no sprite depth auto increment

For Game Lab Documentation / sprite.depth

Here’s my testing code, note that console shows sprites with identical depth values, no auto incrementing seems to be occurring / which the document suggests should happen.

Am I missing something?

when setting a sprites depth you must also consider the fact that the other sprites depth will not change just because you changed one of them. Sprites are drawn in order in which they are created if they are within the same depth layer like s1 and s3 are s1 will always be drawn first in that layer followed by s3 this is because when a sprite is created it is pushed to an allsprites array in which the drawing context renders when you call drawSprites you can fix this by swapping depths with each other

s3.depth = 1;  //  1st
s1.depth = 3; // swap priority

Documentation states

“If you assign a sprite to a depth that is already the depth of another sprite, that other sprite, and all other larger depth sprites, have their depths increased by one.”

Which I think is a little misleading. At this point, I get it. Thanks

I see, unfortunately i am not the person who has written this documentation. If you have issues with specific content that may be misleading you can submit a request here by contacting support if you wish

1 Like