-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Aseprite export format (.json) for animations #379
Conversation
Version: gson 2.8.6
This file is intended to handle importing and exporting of Aseprite JSON files for animations.
This changes the access modifiers of the fields keyframes, name and spritesheet in Animation-class so it can be used in the export process.
This adds the basic structure of Json format aseprite uses.
This reverts commit 083e2c4.
This adds a function that creates the aseprite json as a string representation. it currently only works for the frames object and does not include the meta-data object.
This fixes the broken index when creating the frame objects in aseprite json.
This adds a test for exportAnimation. It prints the constructed json to screen so it can be visualy asserted that it looks like it is supposed too.
This adds so that the meta object is created in the json. The app, version, format, scale and layers are now hardcoded.
Added function AsepriteHandler.importAnimation takes a path to the Aseprite .json file and returns an internal Animation object.
Added a new folder intended to contain test animations that can be used for testing the Aseprite import functionality.
Verifies that the import works as expected when given valid input.
This changes so it is the tests that prints the json not the export function.
Implemented import functionality for Aseprite animations
…bject Fix spritesheetresource object
Added two functions for importing animations. They work much like importspritesheet
Changed imports
Added UI elements to resourcemenu for import
Integration for export. Changed if else statements to switch
GUI integration of import and export
Removes unwanted possible spritesheet paths. Now searches 'image' element in .json data, and same directory as .json for filename of 'image' element and same name as .json with appropriate suffix.
Fix Issue/22
Add some unit tests to importAnimation method.
Amazing, thank you! Please allow us some more time to inspect and assess these changes in detail. |
Fixes a build error. The error was: ``` /home/gamebuster/Desktop/Modding/LitiEngine/src/de/gurkenlabs/litiengine/graphics/animation/AsepriteHandler.java:270: error: cannot infer type arguments for HashMap<K,V> Map<String, Integer> frame = new HashMap<>() {{ ^ reason: cannot use '<>' with anonymous inner classes where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap ```
I've made a PR (DD2480-Group-11#30) to address some issues |
Update Issue/321
Removed unnecessary catch block. Any exceptions are caught by the overarching catch-block instead.
* @param spritesheetResource the animation object to export | ||
* @throws ExportAnimationException if the export fails | ||
*/ | ||
public static String exportAnimation(SpritesheetResource spritesheetResource) throws ExportAnimationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A sprite sheet can have multiple Animations. This method should be taking an Animation, or another method added should be added specifically for Animation objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! Don't confuse Animations (->keyframes) and Spritesheets (-> dimensions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to work on this PR myself (https://github.com/Gamebuster19901/litiengine/tree/gson), but stopped as it requires changes to UtiLITI, as there is no way to select an Animation. You can only select a SpriteSheetResource.
As far as I know, AssetPanelItem.origin
cannot be an Animation
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO I think animations should be considered a resource themselves, because a spritesheet could have multiple animations, and an animation could be played on multiple spritesheets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to work on this PR myself (https://github.com/Gamebuster19901/litiengine/tree/gson), but stopped as it requires changes to UtiLITI, as there is no way to select an Animation. You can only select a SpriteSheetResource.
As far as I know,
AssetPanelItem.origin
cannot be anAnimation
.
I think I'll make another attempt with this PR soon, since UtiLITI is in this repository now, and that makes development a lot easier.
}}; | ||
String spritesheetName = spritesheet.getName(); | ||
Layer[] layers = {new Layer("Layer", 255, "normal")}; | ||
Meta meta = new Meta("http://www.aseprite.org/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use links.properties for external links. Also, I don't really like the in-line version information here. Maybe make that reusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are some welcome and important changes, thank you! Sorry for taking our time with this review. I have noticed some issues that need fixing before I can retest - please address the comments.
* @param spritesheetResource the animation object to export | ||
* @throws ExportAnimationException if the export fails | ||
*/ | ||
public static String exportAnimation(SpritesheetResource spritesheetResource) throws ExportAnimationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! Don't confuse Animations (->keyframes) and Spritesheets (-> dimensions).
@@ -77,6 +79,7 @@ | |||
private static final String TEXTUREATLAS_FILE_NAME = "Texture Atlas XML (generic)"; | |||
|
|||
private static final String IMPORT_DIALOGUE = "import_something"; | |||
private static final String ANIMATION_FILE_NAME = "Animation file"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string should also be localizable.
Closing this due to inactivity. Thank you and feel free to resume at a later point :) |
Adds support for importing/exporting animations as json
This adds the functionality of importing and exporting Aseprite formatted .json files.
Import
In the Resources menu there are now the option to Import Animation, which lets you select a .json file and it will import the corresponding spritesheet that is specified in that json import it to the engine with its data set (duration and so forth).
The import searches for the json like this:
so if 'image'=/animation.png and json=/anim.json, also searches /animation.png and /anim.png
Export
There is also now the option to export an animation as a json in the Aseprite format.
Code coverage
resolve #321