fix sticker order

This commit is contained in:
Lucas 2024-08-03 23:09:14 +02:00
parent 4cf3eb166a
commit c91284051c

View file

@ -88,13 +88,17 @@ func sortByPosY(objects: Array, ascending_order: bool = true):
if _collider is Sticker: if _collider is Sticker:
_tempStickerArray.append(_collider) _tempStickerArray.append(_collider)
if _tempStickerArray.size() > 0: if _tempStickerArray.size() > 0:
_tempStickerArray.sort_custom(compareNodeOrder)
_tempArray = _tempStickerArray _tempArray = _tempStickerArray
_tempArray.sort_custom(comparePosY) else:
_tempArray.sort_custom(comparePosY)
# Reverse if descending order is required # Reverse if descending order is required
if not ascending_order: if not ascending_order:
_tempArray.reverse() _tempArray.reverse()
return _tempArray return _tempArray
func compareNodeOrder(a, b):
return a.get_parent().get_index() < b.get_parent().get_index()
func comparePosY(a, b): func comparePosY(a, b):
#print("Compare ",a," at ",a.position.y, " and ",b," at ",b.position.y ) #print("Compare ",a," at ",a.position.y, " and ",b," at ",b.position.y )
return a.get_parent().position.y < b.get_parent().position.y #Sticker are always at 0, so we need parent position return a.get_parent().position.y < b.get_parent().position.y #Sticker are always at 0, so we need parent position