HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.92k stars 427 forks source link

Batch Async utils #3151

Open Geokureli opened 1 month ago

Geokureli commented 1 month ago

FlxTweens have tween.then(otherTween) which allow chaining, but timers do not have anything like this. Would be nice to have batch timers like the one created for FNF by cyn0x8 in https://github.com/FunkinCrew/Funkin/pull/2391.

Even more so it would be nice if there was an interface or protocol shared by FlxTimer, FlxTween or any other async event that allowed them to be laid out in a single sequence, I.E.

new FlxSequence
(
    [
        FlxTween.tween(obj, {x: targetX }, 2.5, obj.doThing),
        FlxTween.flicker(1.0),// no callback
        FlxTween.tween(obj, {x: targetX }, 2.5, obj.doThing),
        FlxTimer().wait(1.0, doThing2),
        FlxG.camera.shake(0.05, 0.5),
        obj.startAsyncProcess(1.0)
    ],
    onSequenceComplete
)

the above would run each process in sequence, and then call onSequenceComplete