Given source files explaining how to export .swfs, export them.
usage: ./exporter.py [--out dir] [--base dir] source1 source2 source3 ...
Or, if you're not using git bash or some shell that supports shebangs: python exporter.py source1 source2 source3 ...
Source files are JSON files explaining how to export swf(s). They look like:
{ "graphics":[ {"swf":"path/to/file.swf" [,"scale":1] // scale exported images, default = 1 [,"type":1] // 1 (default) for spritesheet export // 2 for skeletal export [,"name":"ExportName"] // defaults to swf file name [,"class_name":"ClassNameOfClipInSwf"]} // defaults to swf file name ], ... }
The graphics
array specifies the swfs to export. If only one swf is specified, that swf will be exported with all its graphics in a .graphic
file given by the name
parameter. If multiple swfs are given, the graphics required for all of them will be exported to a single .asset
pack file given by the name of the source file, and individual .graphic
files will be created for each graphic under their name
, with a single reference pointing to the pack file.
Example source files:
{"graphics":[{"swf":"Player.swf"}]}
produces:
Player.graphic
, containing all the images/sprite info for Player.swf
{"graphics":[{"swf":"Player.swf"},{"swf":"Fighter.swf","name":"Enemy"}]}
(given as Characters.src
) produces:
Characters.asset
, a pack file containing all the graphics from Player.swf
and Fighter.swf
Player.graphic
, a JSON file with a single property pointing to the entry Player
in Characters.asset
Enemy.graphic
, a JSON file with a single property pointing to the entry Enemy
in Characters.asset
In the 2nd case, you can either load Characters.asset
directly, and parse all of the entries in it; or, if you use dynamic loading by requesting a graphic name, requesting the graphic Player
should cause Player.graphic
to be loaded, and the redirection in that should cause Charaters.asset
to be loaded, which should load both Player
and Enemy
into your game.
Graphics are given a path when exported, relative to the base
option, or, if that option is not given, the current directory. Output files are put in a path relative to the out
option if given, or the current directory if omitted.
For instance, exporting Player.src
by running ./exporter.py --base ./graphics --out ./build/assets ./graphics/players.Player.src
will generate the file ./build/assets/players/Player.graphic
Running ./exporter.py [--out dir] [--base dir] -
causes the script to read from stdin; every line will be parsed as an option set [--out dir] [--base dir] source_file
. Useful for automation, for example:
find ./graphics -type f -name '*.src' | ./exporter.py -