diff --git a/core/Cursor.gd b/core/Cursor.gd index a23adc6..24ff43d 100644 --- a/core/Cursor.gd +++ b/core/Cursor.gd @@ -88,13 +88,17 @@ func sortByPosY(objects: Array, ascending_order: bool = true): if _collider is Sticker: _tempStickerArray.append(_collider) if _tempStickerArray.size() > 0: + _tempStickerArray.sort_custom(compareNodeOrder) _tempArray = _tempStickerArray - _tempArray.sort_custom(comparePosY) + else: + _tempArray.sort_custom(comparePosY) # Reverse if descending order is required if not ascending_order: _tempArray.reverse() return _tempArray - + +func compareNodeOrder(a, b): + return a.get_parent().get_index() < b.get_parent().get_index() func comparePosY(a, b): #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