gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
735 stars 93 forks source link

Support Aseprite export format (.json) for animations #321

Open steffen-wilke opened 4 years ago

steffen-wilke commented 4 years ago

Format Documentation:_ https://www.aseprite.org/docs/cli/#filename-format

Aseprite provides a JSON based export format for animation data. It would be great if the engine could support importing this format. Maybe even an export could be useful.

gurke-idle-right-sheet.png

Example JSON for: "gurke-idle-right-sheet.png"

{ "frames": {
   "gurke-idle-right 0.png": {
    "frame": { "x": 0, "y": 0, "w": 40, "h": 40 },
    "rotated": false,
    "trimmed": false,
    "spriteSourceSize": { "x": 0, "y": 0, "w": 40, "h": 40 },
    "sourceSize": { "w": 40, "h": 40 },
    "duration": 120
   },
   "gurke-idle-right 1.png": {
    "frame": { "x": 40, "y": 0, "w": 40, "h": 40 },
    "rotated": false,
    "trimmed": false,
    "spriteSourceSize": { "x": 0, "y": 0, "w": 40, "h": 40 },
    "sourceSize": { "w": 40, "h": 40 },
    "duration": 120
   },
   "gurke-idle-right 2.png": {
    "frame": { "x": 80, "y": 0, "w": 40, "h": 40 },
    "rotated": false,
    "trimmed": false,
    "spriteSourceSize": { "x": 0, "y": 0, "w": 40, "h": 40 },
    "sourceSize": { "w": 40, "h": 40 },
    "duration": 120
   }
 },
 "meta": {
  "app": "http://www.aseprite.org/",
  "version": "1.2.16.3-x64",
  "image": "gurke-idle-right-sheet.png",
  "format": "RGBA8888",
  "size": { "w": 120, "h": 40 },
  "scale": "1",
  "frameTags": [
  ],
  "layers": [
   { "name": "Layer", "opacity": 255, "blendMode": "normal" }
  ],
  "slices": [
  ]
 }
}
danhalv commented 3 years ago

I'm working in a group with @DD2480-Group-11 and we were interested in working on this. The project doesn't seem to be using any JSON libraries, would json-simple work? Also, what files would require integration (importing from toolbar etc.)?

Gamebuster19901 commented 3 years ago

I would recommend gson https://github.com/google/gson

Gamebuster19901 commented 3 years ago

I think this requires Animation to become a Resource.

Currently, you can export a spritesheet, but that's not the same as exporting an animation, as a spritesheet can have multiple animations.