2022-03-08 03:13:53 -05:00
|
|
|
package funkin.util;
|
2022-01-26 14:19:57 -05:00
|
|
|
|
2022-02-23 16:49:54 -05:00
|
|
|
#if !macro
|
2022-03-11 01:30:01 -05:00
|
|
|
import flixel.FlxBasic;
|
2022-01-26 14:19:57 -05:00
|
|
|
import flixel.util.FlxSort;
|
2022-02-23 16:49:54 -05:00
|
|
|
#end
|
2022-01-26 14:19:57 -05:00
|
|
|
|
|
|
|
class SortUtil
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* You can use this function in FlxTypedGroup.sort() to sort FlxObjects by their z-index values.
|
|
|
|
* The value defaults to 0, but by assigning it you can easily rearrange objects as desired.
|
|
|
|
*/
|
2022-03-11 01:30:01 -05:00
|
|
|
public static inline function byZIndex(Order:Int, Obj1:FlxBasic, Obj2:FlxBasic):Int
|
2022-01-26 14:19:57 -05:00
|
|
|
{
|
|
|
|
return FlxSort.byValues(Order, Obj1.zIndex, Obj2.zIndex);
|
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Given two Notes, returns 1 or -1 based on whether `a` or `b` has an earlier strumtime.
|
|
|
|
*
|
|
|
|
* @param order Either `FlxSort.ASCENDING` or `FlxSort.DESCENDING`
|
|
|
|
*/
|
|
|
|
public static inline function byStrumtime(order:Int, a:Note, b:Note)
|
|
|
|
{
|
|
|
|
return FlxSort.byValues(order, a.data.strumTime, b.data.strumTime);
|
|
|
|
}
|
2022-01-26 14:19:57 -05:00
|
|
|
}
|