As of r252 support for importing animations frames from zip files and folders has been implemented, and as is usually the case, there are a few things which are not immediately obvious about the feature. So let's talk about that.
Let's start with the basic use cases.
Basics
Importing folders
- Dragging and dropping a folder into the Animations panel, will create a new sub folder with a new animation inside of it. The animation will have frames for all images found at the root level of the folder. Both the new sub folder and the animation will have the name of the dropped folder.
- Dragging and dropping a folder into the Frames panel or the Main drawing area will add all the individual images in the folder as frames of the current animation.
Importing zip files
- Dragging and dropping a zip file into the Animations panel, will create a new animation with all images found at the root level of the zip file. The animation will have the same name as the zip file.
- Dragging and dropping a zip file into the Frames panel or the Main drawing area will add all the individual images in the zip file as frames of the current animation.
Importing from the toolbar options
The toolbar Load button now has two options. Load frames and Load animations.
- Load frames allows you to pick images to be loaded as frames of the current animation. Is is now also possible to pick zip files from the file picker. All images in a zip file will be added as frames of the current animation.
- Load animations allows you to pick images to be loaded into a new animation. Is is now also possible to pick zip files from the file picker. A new animation will be created with all of the individual images picked, while each picked zip file will correspond to a new animation being created.
Nested content
Folders and zip files which in turn also have folders and zip files inside of them are supported, depending on how you try to import these, this is how C3 will behave.
- Dropping in the Animations Panel: C3 will process everything and create animations and sub folders as needed.
- Dropping in the Frames Panel or Drawing Area: all of the nested content will be turned into a flat list and added as frames to the current animation.
- Toolbar Load Frames option: all the nested content inside a zip file will be turned into a flat list and added to the current animation.
- Toolbar Load Animations option: if a zip file with nested content is loaded, the images at the root level of the zip will be used to create an animation, if other zip files are found, new animations will be created for them. If a folder is found in a zip file, a sub folder with an animation inside of it will be created, following the same patters as importing a folder.
The key points to remember are:
- Importing folders will create a sub folder with an animation inside of it, both named after the original folder. The animation will have frames corresponding to the images found at the root level of the original folder.
- Importing zip files will create an animation named after the zip file and will have frames corresponding to all the images found at the root level of the zip file.
- If nested content is found, the same pattern applies. Each folder will correspond to a new sub folder with a new animation inside of it. Each zip file will correspond to a new animation.
Optional configuration file
Normally when importing a single file, C3 asks if the file should be treated as a sprite sheet or as a single file. In the case of importing multiple files this isn't really an option. Because of that, when importing folders or zips, even if an animation ends up having only one frame, C3 never asks how it it should be treated.
To get around this problem, a special configuration file can be added to a folder or zip file to tell C3 how it should handle the files found on them.
It's a simple JSON file, must be named c3-import-settings.json and should look like this:
{
"import-mode": "spritesheet",
"sort": "alphabetical",
"order": "ascending",
"replace-existing-animation": false,
"replace-existing-folder": false,
"use-raw-folder-names": false,
"spritesheet": {
"horizontal-cells": 4,
"vertical-cells": 4,
"direction": "horizontal"
},
"svg": {
"width": 100,
"height": 100
},
"animation": {
"name": "optional-animation-name",
"speed": 5,
"loop": false,
"repeat-count": 1,
"repeat-to": 0,
"ping-pong": false,
"frame-durations": [1, 2, 3, 4],
"frame-collision-polys": [
{"points":[0,0,1,0,1,1,0,1]},
{"points":[0,0,1,0,1,1,0,1]},
{"points":[0,0,1,0,1,1,0,1]},
{"points":[0,0,1,0,1,1,0,1]}
],
"frame-image-points":[
[{"originX":0.5,"originY":0.5}, {"name":"Image Point 1","x":0.5,"y":0.5}],
[{"originX":0.5,"originY":0.5}],
[{"originX":0.5,"originY":0.5}],
[{"originX":0.5,"originY":0.5}]
],
"frame-tags":["tag-1", "tag-2", "tag-3", "tag-4"]
}
}
This special file can be placed at the root of a folder or zip structure and will affect all content found.
Another file with the same name can be placed further down the hierarchy and will take precedence over the ones found before. That way you can configure different sets of files to be interpreted differently when imported.
I think that covers everything about this new feature.