Skip to content

Commit 65c3e6e

Browse files
committed
Use ZIndex in the Arena
1 parent 8225e34 commit 65c3e6e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00400-part-3.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ To render both Circle and Food entities we need a way to draw circles on the scr
971971
```csharp
972972
using Godot;
973973

974-
public partial class Circle2D : Node2D
974+
public abstract partial class Circle2D : Node2D
975975
{
976976
private float _radius = 10.0f;
977977
[Export]
@@ -1584,7 +1584,8 @@ private void SetupArena(float worldSize)
15841584
Name = "Background",
15851585
Color = BackgroundColor,
15861586
Position = Vector2.Zero,
1587-
Polygon = polygon
1587+
Polygon = polygon,
1588+
ZIndex = -1000
15881589
};
15891590
background.AddChild(new Polygon2D
15901591
{
@@ -1595,13 +1596,13 @@ private void SetupArena(float worldSize)
15951596
InvertBorder = BorderThickness,
15961597
Polygon = polygon
15971598
});
1598-
AddChild(background, @internal: InternalMode.Front);
1599+
AddChild(background);
15991600

16001601
AddChild(new CameraController(worldSize));
16011602
}
16021603
```
16031604

1604-
Note that we added a new parameter to the first `AddChild` where we add the `background`: `@internal: InternalMode.Front`. This is to tell Godot to add this child (the background) before the other siblings, so it goes behind the `Instantiator` that we added earlier.
1605+
Note that we defined a negative `ZIndex` to `background`. This is so it gets render behind all the other siblings (instantiated by the `Instantiator` that we added earlier).
16051606

16061607
### Entering the Game
16071608

0 commit comments

Comments
 (0)