Skip to content

Commit 72a0e80

Browse files
Merge branch 'fix-sdk-group-issues' into 'master'
[FIX][SDK] Fixed issues with Groups See merge request codingame/game-engine!312
2 parents 4e7ab3a + b917c24 commit 72a0e80

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/BufferedGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* This reduces artifacts caused by rounding errors at the cost of lower performance.
88
* </p>
99
*/
10-
public class BufferedGroup extends ContainerBasedEntity<BufferedGroup> {
10+
public class BufferedGroup extends ContainerBasedEntity<BufferedGroup> implements Mask {
1111
@Override
1212
Entity.Type getType() {
1313
return Entity.Type.BUFFERED_GROUP;

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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const api = {}
66

77
export class GraphicEntityModule {
88
constructor (assets) {
9+
window.entityModule = this
910
this.entities = new Map()
1011
this.frames = []
1112
this.loadingAssets = 0
@@ -117,7 +118,6 @@ export class GraphicEntityModule {
117118
this.globalData.toPixel = (WIDTH / canvasData.width) * canvasData.oversampling
118119
this.globalData.mustResetTree = true
119120
api.container = this.container = container
120-
container.sortableChildren = true
121121
this.entities.forEach((e) => {
122122
e.init()
123123
})
@@ -167,6 +167,7 @@ export class GraphicEntityModule {
167167
e.childrenContainer.addChild(child.container)
168168
child.parent = e
169169
})
170+
this.sortContainerChildren(e.childrenContainer)
170171
e.notifyChange()
171172
}
172173
})
@@ -177,6 +178,13 @@ export class GraphicEntityModule {
177178
this.container.addChild(e.container)
178179
}
179180
})
181+
this.sortContainerChildren(this.container)
182+
}
183+
184+
sortContainerChildren(container) {
185+
container.children.sort(
186+
(a,b) => a.zIndex === b.zIndex ? a.id - b.id : a.zIndex - b.zIndex
187+
)
180188
}
181189

182190
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)