forked from Hubs-Foundation/spritesheet.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zebkit.template
29 lines (25 loc) · 847 Bytes
/
zebkit.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// create 'images' package
var masv = masv || zebra.namespace("masv");
masv("images");
(function() {
var pkg = masv.images;
var sheet={
"image": "{{{name}}}.png",
"frames": [
{{#files}}
[{{x}}, {{y}}, {{width}}, {{height}}]{{^isLast}},{{/isLast}} //{{{name}}}
{{/files}}
],
"sprites": {
{{#files}}
"{{{name}}}":[{{index}}]{{^isLast}},{{/isLast}}
{{/files}}
}
};
var atlas = new Image();
atlas.src=sheet.image;
var process = function(coords) { return new zebra.ui.Picture(atlas, coords[0], coords[1], coords[2], coords[3])};
var evalStr='';
for (var i=0;i<sheet.frames.length;i++) evalStr+='pkg.'+Object.keys(sheet.sprites)[i]+'=process(['+sheet.frames[i]+']);';
eval(evalStr);
}());