From 509ad2e1d7f68e19007e78d9ac2eafa9f6417291 Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 9 Oct 2023 19:37:11 -0600 Subject: [PATCH] show all loaded tag/animations and indicator of which is playing. expand docs --- Other/FlxAspriteUtils/README.md | 15 ++++++++-- Other/FlxAspriteUtils/assets/pointer.png | Bin 0 -> 140 bytes Other/FlxAspriteUtils/source/PlayState.hx | 34 ++++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 Other/FlxAspriteUtils/assets/pointer.png diff --git a/Other/FlxAspriteUtils/README.md b/Other/FlxAspriteUtils/README.md index a049880e7..52a5f9a68 100644 --- a/Other/FlxAspriteUtils/README.md +++ b/Other/FlxAspriteUtils/README.md @@ -5,10 +5,21 @@ Demonstrates how to utilize Aseprite art files with the built-in FlxAsepriteUtil ## Table of Contents * [Files](#files) - +* [Aseprite Export](#aseprite-export) ### Files * `player.ase` - Aseprite file built using Character Animations from Kenney.nl (https://www.kenney.nl/assets/platformer-characters) * `player.png` - Sprite sheet exported from Aseprite. See [Aseprite Export](#aseprite-export) for details. -* `player.json` - Atlas frame data exported from Aseprite. See [Aseprite Export](#aseprite-export) for details. \ No newline at end of file +* `player.json` - Atlas frame data exported from Aseprite. See [Aseprite Export](#aseprite-export) for details. + +### Aseprite Export + +There are two main ways of exporting sprite sheets from Aseprite: + + * UI + * See the [Official UI Docs](https://www.aseprite.org/docs/sprite-sheet/#export) + * Requires user interaction, but allows fore preview to visualize sprite sheet settings + * CLI + * See the [Official CLI Docs](https://www.aseprite.org/docs/cli/) + * Useful for automated workflows \ No newline at end of file diff --git a/Other/FlxAspriteUtils/assets/pointer.png b/Other/FlxAspriteUtils/assets/pointer.png new file mode 100644 index 0000000000000000000000000000000000000000..4c68e95b47767766ad21fd83c0462b5574a5665f GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W^!3HFa4)S;aDaPU;cPEB*=VV?2Ic}aVjv*Qo z*IsbsV-VnRx%l&4eY%;)lqpHq-g;XHDeOEpTan3Zi~iv)@@%?UiDmjOOdmw2Ecqgw n9Qw-h4qyC++s$k_*DD$2PpSXhb&_o7LS3j3^P6; var currentAnimationLabel:FlxText; var player:FlxSprite; + var curAnimIndex = 0; + var pointer:FlxSprite; + var nextButton:FlxButton; var previousButton:FlxButton; @@ -27,23 +36,42 @@ class PlayState extends FlxState player.screenCenter(); add(player); + animList = player.animation.getAnimationList(); + + loadedAnimations = new FlxText(20); + loadedAnimations.text = animList.map((a) -> { a.name; }).join("\n"); + loadedAnimations.screenCenter(Y); + add(loadedAnimations); + + pointer = new FlxSprite("assets/pointer.png"); + add(pointer); + currentAnimationLabel = new FlxText(player.animation.name); currentAnimationLabel.alignment = CENTER; currentAnimationLabel.y = FlxG.height - currentAnimationLabel.height; add(currentAnimationLabel); previousButton = new FlxButton("Previous", () -> { - + setPlayerAnim(curAnimIndex-1); }); previousButton.setPosition(0, FlxG.height - previousButton.height); add(previousButton); nextButton = new FlxButton("Next", () -> { - + setPlayerAnim(curAnimIndex+1); }); nextButton.setPosition(FlxG.width - nextButton.width, FlxG.height - nextButton.height); add(nextButton); + + setPlayerAnim(0); + } + + function setPlayerAnim(index:Int) { + curAnimIndex = index % animList.length; + player.animation.play(animList[curAnimIndex].name); + + pointer.setPosition(0, POINTER_VERTICAL_OFFSET + loadedAnimations.y + ANIM_NAME_LINE_SPACING * curAnimIndex); } override function update(elapsed:Float) {