flixel icon indicating copy to clipboard operation
flixel copied to clipboard

frame events?

Open Geokureli opened this issue 2 years ago • 2 comments

It seems like a very useful thing to be able to fire an event when a certain frame of a certain animation is reached.

I'll likely make my own thing in a test project and if it seems like a good universal approach maybe i'll add it to flixel

Eggu in the discord brought this idea to my attention, and I've thought about it before

Geokureli avatar May 23 '23 22:05 Geokureli

Is this different than doing something like setting the callback variable in FlxSprite.animation / FlxAnimationController?

https://api.haxeflixel.com/flixel/animation/FlxAnimationController.html#callback

callback:(name:String, frameNumber:Int, frameIndex:Int) ‑> Void If assigned, will be called each time the current animation's frame changes. A function that has 3 parameters: a string name, a frame number, and a frame index.

ninjamuffin99 avatar Sep 20 '23 01:09 ninjamuffin99

Is this different than doing something like setting the callback variable in FlxSprite.animation / FlxAnimationController?

https://api.haxeflixel.com/flixel/animation/FlxAnimationController.html#callback

callback:(name:String, frameNumber:Int, frameIndex:Int) ‑> Void If assigned, will be called each time the current animation's frame changes. A function that has 3 parameters: a string name, a frame number, and a frame index.

yes, rather than a single callback that handles every frame change, this would be a specific event on a specific fame of a specific animation. This wouldn't replace the callback, only serve as another option.

Example: say frame 6 of the "attack" animation is when you want to check collision or play a sound or something, you would specifically listen for that and be able to remove it without affecting any other events or needing to change the callback that handles every other event.

Geokureli avatar Oct 02 '23 18:10 Geokureli