Skip to content

Commit 5c7d511

Browse files
committed
fix(sdk): Children are now ordered by zIndex, then id in groups
1 parent b9976c5 commit 5c7d511

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

engine/modules/entities/src/main/resources/view/entity-module/BufferedGroup.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export class BufferedGroup extends ContainerBasedEntity {
77
initDisplay () {
88
super.initDisplay()
99
this.buffer = new PIXI.Container()
10-
this.buffer.sortableChildren = true
1110
this.gameTexture = null
1211
this.graphics = new PIXI.Sprite()
1312
this.needsRender = true

engine/modules/entities/src/main/resources/view/entity-module/ContainerBasedEntity.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class ContainerBasedEntity extends Entity {
1313
initDisplay () {
1414
super.initDisplay()
1515
this.graphics = new PIXI.Container()
16-
this.graphics.sortableChildren = true
1716
}
1817

1918
updateDisplay (state, changed, globalData) {

engine/modules/entities/src/main/resources/view/entity-module/GraphicEntityModule.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class GraphicEntityModule {
117117
this.globalData.toPixel = (WIDTH / canvasData.width) * canvasData.oversampling
118118
this.globalData.mustResetTree = true
119119
api.container = this.container = container
120-
container.sortableChildren = true
121120
this.entities.forEach((e) => {
122121
e.init()
123122
})
@@ -167,6 +166,7 @@ export class GraphicEntityModule {
167166
e.childrenContainer.addChild(child.container)
168167
child.parent = e
169168
})
169+
this.sortContainerChildren(e.childrenContainer)
170170
e.notifyChange()
171171
}
172172
})
@@ -177,6 +177,13 @@ export class GraphicEntityModule {
177177
this.container.addChild(e.container)
178178
}
179179
})
180+
this.sortContainerChildren(this.container)
181+
}
182+
183+
sortContainerChildren(container) {
184+
container.children.sort(
185+
(a,b) => a.zIndex === b.zIndex ? a.id - b.id : a.zIndex - b.zIndex
186+
)
180187
}
181188

182189
handleGlobalData (players, globalData) {

playground/misc/misc-3-release-notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
The CodinGame SDK is regularly updated and improved. This document lets you know what changed in the latest releases.
44

5+
## Next Release
6+
7+
### 🎁 Features
8+
9+
- `BufferedGroups` can now be used as masks.
10+
11+
### 🐞 Bug fix
12+
13+
- Children with equal `zIndices` are now rendered by order of insertion in `Groups` and `BufferedGroups`.
14+
515
## 4.2.1
616

717
### 🐞 Bug fix

0 commit comments

Comments
 (0)