If got an Entity Component System based game-project (like classic zelda).
- The Player as well as Enemys are Entities with sprite- and tranform-components.
- The Weapons are also Entities with sprite- and tranform-components.
- The player and the Enemies can pickup weapons.
- Weapons got an ParentComponent so they will be rendered realtive to the Carrier-Entity.
- There is a script/system for that.
- No everytime an player/enemy walks upwards, the weapon must rendered BEHIND/under the carrier for the illution, that the player walks to the top of the screen.
- I will do this by switching the Z-Index of the transform-component of the carrier with the one of the weapon.
- Unfortunately, the rendering system is a Sorted-Iterating-System which holds a sorted list of all entities with Sprite-Components so everytime Im changing the Z-Index of an Entity, I have to force the re-sortening of the list.
- This works but sorting an entire list in java almost every gamellop-update sounds very bad.
Is this really a good idea or should I try something else? BTW: In practice, Im using libGdx with Ashley as the ECS.