# Game Lab, no sprite depth auto increment

**URL:** <https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640>\
**Category:** Coding and Debugging Help\
**Created:** [April 5, 2025, 1:48am UTC](https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640 "2025-04-05T01:48:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fshaul](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/fshaul/32/9350_2.png) [@fshaul](https://forum.code.org/u/fshaul)\
**Post date:** [April 5, 2025, 1:48am UTC](https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640/1 "2025-04-05T01:48:48Z")

</div>

For Game Lab Documentation / sprite.depth

> **[Code.org \[staging\]](https://staging-studio.code.org/docs/ide/gamelab/expressions/depth)**
>
> Anyone can learn computer science. Make games, apps and art with code.

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.

> **[Check out what I made](https://studio.code.org/projects/gamelab/50nEaFrnT7TV08uvL4ee9QThowcQf9UTjm-a3G2q8tw)**
>
> I wrote the code myself with Code.org

Am I missing something?

---

<div class="post-metadata">

**Author:** ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)\
**Post date:** [April 6, 2025, 1:32am UTC](https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640/2 "2025-04-06T01:32:32Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![fshaul](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/fshaul/32/9350_2.png) [@fshaul](https://forum.code.org/u/fshaul)\
**Post date:** [April 11, 2025, 11:26pm UTC](https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640/3 "2025-04-11T23:26:00Z")

</div>

> **[Code.org](https://studio.code.org/docs/ide/gamelab/expressions/depth)**
>
> Anyone can learn computer science. Make games, apps and art with code.

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

---

<div class="post-metadata">

**Author:** ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)\
**Post date:** [April 12, 2025, 12:12am UTC](https://forum.code.org/t/game-lab-no-sprite-depth-auto-increment/40640/4 "2025-04-12T00:12:09Z")

</div>

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](https://support.code.org/hc/en-us/requests/new) by contacting support if you wish
