1 decade ago by Krasik
Hello.
I&
Just need to sort entities by zIndex and it works but something weird is happening on my screen.
This is what im doing:
In entity update()
in main update()
It&
This is what happening on my screen with main update code:
https://www.youtube.com/watch?v=mpwy6KdQnnU&feature=youtu.be
Followed entities are lagging a bit.
And this is without sorting code:
https://www.youtube.com/watch?v=23AihUHltLk&feature=youtu.be
Every move is smooth.
This lagging problem also occurs when autoSort in ig.game is set on true. This not helping with sort by zIndex, only lagging entities.
Any thoughts on how to fix?
I&
039;m having some issues with dynamic sorting using #ig.game.sortEntitiesDeferred()
Just need to sort entities by zIndex and it works but something weird is happening on my screen.
This is what im doing:
In entity update()
this.zIndex = Math.floor(this.pos.y);
in main update()
if (typeof ig.game.layersMap["entities"] != "undefined") { for (var i = 0; i < ig.game.layersMap["entities"].items.length - 1; i++) { if (ig.game.layersMap["entities"].items[i].zIndex > ig.game.layersMap["entities"].items[i + 1].zIndex) ig.game.layersMap["entities"].items.sort(function(a,b) { return a.zIndex - b.zIndex; }); } }
It&
039;s exactly what #ig.game.sortEntitiesDeferred()
do but im doing it only when zIndex changes.This is what happening on my screen with main update code:
https://www.youtube.com/watch?v=mpwy6KdQnnU&feature=youtu.be
Followed entities are lagging a bit.
And this is without sorting code:
https://www.youtube.com/watch?v=23AihUHltLk&feature=youtu.be
Every move is smooth.
This lagging problem also occurs when autoSort in ig.game is set on true. This not helping with sort by zIndex, only lagging entities.
Any thoughts on how to fix?