Skip to content

Commit

Permalink
Added ability to string sequences together into animations
Browse files Browse the repository at this point in the history
  • Loading branch information
mildfuzz committed Oct 2, 2013
1 parent 324f701 commit c451a1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/generator.js 100644 → 100755
Expand Up @@ -158,6 +158,24 @@ exports.generateData = function (files, options, callback) {
item.trim.offsetY = Math.floor(Math.abs(item.trim.y + item.height / 2 - item.trim.height / 2));
}
});
/**
* Groups files with numeric endings together
*/
if(options.f === "easel.js"){
var animations = [], filenames = [];
options.files.forEach(function(file){
var filename = file.name.replace(/\d+$/g,'');
var index = filenames.indexOf(filename);
if(index >= 0){
animations[index].frames = animations[index].frames+', '+String(file.index);
} else {
animations.push({name:filename,frames:String(file.index)});
filenames.push(filename);
}
});
options.animations = animations;
options.animations[options.animations.length-1].isLast = true;
}
var result = Mustache.render(tempateContent, options);
fs.writeFile(options.path + '/' + options.name + '.' + options.format.extension, result, callback);
};
Expand Down
6 changes: 3 additions & 3 deletions templates/easeljs.template 100644 → 100755
Expand Up @@ -6,8 +6,8 @@
{{/files}}
],
"animations": {
{{#files}}
"{{name}}":[{{index}}]{{^isLast}},{{/isLast}}
{{/files}}
{{#animations}}
"{{name}}":[{{frames}}]{{^isLast}},{{/isLast}}
{{/animations}}
}
}

0 comments on commit c451a1c

Please sign in to comment.