Fix Y sorting and filter by type
This commit is contained in:
parent
0be8633a7e
commit
4cf3eb166a
1 changed files with 9 additions and 3 deletions
|
@ -50,7 +50,7 @@ func pointcast():
|
|||
#endregion
|
||||
if (hoveredColliders.size() > 0):
|
||||
if (hoveredColliders.size() >= 2):
|
||||
sortByPosY(hoveredColliders,false)
|
||||
hoveredColliders = sortByPosY(hoveredColliders,false)
|
||||
if (hoveredColliders[0] != hoveredCollider):
|
||||
$GrabTimer.stop()
|
||||
if (hoveredCollider and hoveredCollider.has_method("on_unhover")):
|
||||
|
@ -81,13 +81,19 @@ func resetCast(bFull = false):
|
|||
## Sort objects by parent's Y position
|
||||
func sortByPosY(objects: Array, ascending_order: bool = true):
|
||||
var _tempArray :Array
|
||||
var _tempStickerArray :Array
|
||||
_tempArray = objects
|
||||
# Inline comparison function
|
||||
#filter stickers
|
||||
for _collider in _tempArray:
|
||||
if _collider is Sticker:
|
||||
_tempStickerArray.append(_collider)
|
||||
if _tempStickerArray.size() > 0:
|
||||
_tempArray = _tempStickerArray
|
||||
_tempArray.sort_custom(comparePosY)
|
||||
# Reverse if descending order is required
|
||||
if not ascending_order:
|
||||
_tempArray.reverse()
|
||||
objects = _tempArray
|
||||
return _tempArray
|
||||
|
||||
func comparePosY(a, b):
|
||||
#print("Compare ",a," at ",a.position.y, " and ",b," at ",b.position.y )
|
||||
|
|
Loading…
Reference in a new issue