One particular problem when implementing this story is in which order to render layers and objects. The rendering itself can not be implemented as an own RenderLayer
since GameObject
instances should get rendered before or after a certain layer. In addition GameObject
instances for layers should not be taken into account for collision detection or world deletion. This can be achieved by treating a MapLayer
as a game object and assigning own renderers for each layer individually. Afterwards braingdx needs to calculate the z-index for every GameObject
to decide in which order to render:
index = (layerIndex + 1) * rowCount + yPosition