mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-12-04 21:31:15 -05:00
42d8d55067
* Initial test suite * Fix some build warnings * Implemented working unit tests with coverage * Reduced some warnings * Fix a mac-specific issue * Add 2 additional unit test classes. * Multiple new unit tests * Some fixins * Remove auto-generated file * WIP on hiding ignored tests * Added list of debug hotkeys * Remove old website * Remove empty file * Add more unit tests * Fix bug where arrows would nudge BF * Fix bug where ctrl/alt would flash capsules * Fixed bug where bf-old easter egg broke * Remove duplicate lines * More test-related stuff * Some code cleanup * Add mocking and a test assets folder * More TESTS! * Update Hmm... * Update artist on Monster * More minor fixes to individual functions * 1.38% unit test coverage! * Even more tests? :O * More unit test work * Rework migration for BaseRegistry * gameover fix * Fix an issue with Lime * Fix issues with version parsing on data files * 100 total unit tests! * Added even MORE unit tests! * Additional test tweaks :3 * Fixed tests on windows by updating libraries. * Set versions for flixel-ui and hamcrest --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
59 lines
1.9 KiB
Haxe
59 lines
1.9 KiB
Haxe
package funkin.util.assets;
|
|
|
|
import flixel.FlxSprite;
|
|
import flixel.graphics.frames.FlxFramesCollection;
|
|
import funkin.data.animation.AnimationData;
|
|
|
|
class FlxAnimationUtil
|
|
{
|
|
/**
|
|
* Properly adds an animation to a sprite based on the provided animation data.
|
|
*/
|
|
public static function addAtlasAnimation(target:FlxSprite, anim:AnimationData)
|
|
{
|
|
var frameRate = anim.frameRate == null ? 24 : anim.frameRate;
|
|
var looped = anim.looped == null ? false : anim.looped;
|
|
var flipX = anim.flipX == null ? false : anim.flipX;
|
|
var flipY = anim.flipY == null ? false : anim.flipY;
|
|
|
|
if (anim.frameIndices != null && anim.frameIndices.length > 0)
|
|
{
|
|
// trace('addByIndices(${anim.name}, ${anim.prefix}, ${anim.frameIndices}, ${frameRate}, ${looped}, ${flipX}, ${flipY})');
|
|
target.animation.addByIndices(anim.name, anim.prefix, anim.frameIndices, '', frameRate, looped, flipX, flipY);
|
|
// trace('RESULT:${target.animation.getAnimationList()}');
|
|
}
|
|
else
|
|
{
|
|
// trace('addByPrefix(${anim.name}, ${anim.prefix}, ${frameRate}, ${looped}, ${flipX}, ${flipY})');
|
|
target.animation.addByPrefix(anim.name, anim.prefix, frameRate, looped, flipX, flipY);
|
|
// trace('RESULT:${target.animation.getAnimationList()}');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Properly adds multiple animations to a sprite based on the provided animation data.
|
|
*/
|
|
public static function addAtlasAnimations(target:FlxSprite, animations:Array<AnimationData>)
|
|
{
|
|
for (anim in animations)
|
|
{
|
|
addAtlasAnimation(target, anim);
|
|
}
|
|
}
|
|
|
|
public static function combineFramesCollections(a:FlxFramesCollection, b:FlxFramesCollection):FlxFramesCollection
|
|
{
|
|
var result:FlxFramesCollection = new FlxFramesCollection(null, ATLAS, null);
|
|
|
|
for (frame in a.frames)
|
|
{
|
|
result.pushFrame(frame);
|
|
}
|
|
for (frame in b.frames)
|
|
{
|
|
result.pushFrame(frame);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|