When we last worked on our drawing system we implemented the ability to sort our spites using a sort order, where sprites with a higher sort order appear in front of sprites with a lower sort order. This is helped us sort our tilemap layers so they appear in the correct order. This week I want to take this concept a step further and implement drawing layers. If you’ve ever used Unity (and most likely other game engines) before then you have most likely used drawing layers.
The comparison function must be static because it must have two arguments (in this case object a and object b), and non-static functions have a hidden first parameter that points to the class that owns the function. I won’t go into detail about how this works but you can find more information here if you are interested.
Not a huge change: rather than adding the object we now add the drawable component.