diff --git a/app/ecs/components/sprite.js b/app/ecs/components/sprite.js index aa19198..0fe772f 100644 --- a/app/ecs/components/sprite.js +++ b/app/ecs/components/sprite.js @@ -215,5 +215,6 @@ export default class Sprite extends Component { source: {type: 'string'}, speed: {type: 'float32'}, tint: {defaultValue: 0xffffff, type: 'uint32'}, + zIndex: {defaultValue: 65535, type: 'uint16'}, }; } diff --git a/app/react/components/pixi/entity.js b/app/react/components/pixi/entity.js index 7d520c0..165d0d2 100644 --- a/app/react/components/pixi/entity.js +++ b/app/react/components/pixi/entity.js @@ -106,10 +106,17 @@ export default class Entity { const {x, y} = this.entity.Position; this.container.x = x; this.container.y = y; - this.container.zIndex = y; + if (this.entity.Sprite?.zIndex === 65535) { + this.container.zIndex = y; + } } if (Sprite) { const {diffuse, normals} = this; + if (!this.attached || 'zIndex' in Sprite) { + this.container.zIndex = this.entity.Sprite?.zIndex === 65535 + ? this.entity.Position.y + : this.entity.Sprite.zIndex; + } if (!this.attached || 'alpha' in Sprite) { diffuse.alpha = normals.alpha = this.entity.Sprite.alpha; }