My table.sort doesn't work
Posted: Thu Dec 26, 2024 1:06 am
I'm developing a game and the character is divided into parts and I'm trying to make a code that makes the sprites not messed up when the character rotates using table.sort, the problem is that with or without this function it remains messy
part of the code that SHOULD fix the order of the sprites
I've been researching how to fix it for a while and now all I can do is ask on the love 2d website
part of the code that SHOULD fix the order of the sprites
Code: Select all
local sort = function(a, b) return a.z < b.z end
table.sort(p.body, sort)
for i, b in pairs(p.body)do b.grid = newGrid(0, p.dir, 65, 65) end --this selects each sprite for each body part
I've been researching how to fix it for a while and now all I can do is ask on the love 2d website