GroupTools.bringToFront() and sendToBack(). Close #97

This commit is contained in:
2022-07-26 17:50:02 +00:00
parent db99dbc939
commit 410bd7f96d
3 changed files with 21 additions and 0 deletions

View File

@@ -1,3 +1,18 @@
(function :Void clearNulls <>[:FlxObject T] [:FlxTypedGroup<T> group]
(while (contains group.members null)
(group.members.splice (group.members.lastIndexOf null) 1)))
// Because FlxGroup will fill elements into null gaps in groups, this method inefficiently clears null gaps
(function :Void bringToFront <>[:FlxObject T] [:FlxTypedGroup<T> group :T obj]
(group.remove obj true)
(clearNulls group)
(group.add obj))
// Because FlxGroup will fill elements into null gaps in groups, this method throws an error when a null gap is present
(function :Void sendToBack <>[:FlxObject T] [:FlxTypedGroup<T> group :T obj]
(group.remove obj true)
(group.insert 0 obj))
(function :FlxRect calculateBounds <>[:FlxObject T] [:FlxTypedGroup<T> group &opt :Float margin]
(unless margin (set margin 0))
(let [&mut minX 0