Image sorting crashes app when i want to force certain images to be drawn behind others #88
-
I followed your RPG tutorial on Youtube and am currently working on a 2d platform game where I have tombs/zombie spawn sites whose image I always want to have drawn behind other entities. I've implemented a simple way of seting a flag on the ImageComponent when I want the Image to always be drawn behind to other as followed. It works for a while and the zombie spawn tomb is now always drawn behind other Entity images, but after a little time the app always crashes with a StackOverflow (see stacktarce below).
Stacktrace: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Looks like I found a way to prevent the SO crash as followed:
I assume this prevents an endless loop in the BagKt.quickSort function. |
Beta Was this translation helpful? Give feedback.
-
Ah I was to slow but seems like my assumption was correct. Sorting did not work in your first version and caused an endless loop because you did not provide a unique sorting order per element. Anyway, you can also take over my example which allows you to use any Z value for your entities. E.g. -1 would be background, 1 is foreground and 0 is in between. But you are not limited to that and can use an arbitrary amount of z values (=layers). |
Beta Was this translation helpful? Give feedback.
Looks like I found a way to prevent the SO crash as followed:
I assume this prevents an endless loop in the BagKt.quickSort function.