lycwed-spritesheetjs
Version:
Spritesheet generator
126 lines (121 loc) • 5.2 kB
JavaScript
// create 'images' package
var masv = masv || zebra.namespace("masv");
masv("images");
(function() {
var pkg = masv.images;
var sheet={
"image": "spritesheet.png",
"frames": [
[], //button
[], //button_active
[], //button_hover
[], //character_evil
[], //character_hero
[], //fx_particle_bomb
[], //fx_particle_boom_01
[], //fx_particle_boom_02
[], //fx_particle_boom_03
[], //fx_particle_bullett
[], //fx_particle_crash_01
[], //fx_particle_crash_02
[], //fx_particle_crash_03
[], //fx_particle_crash_04
[], //fx_particle_engine_01
[], //fx_particle_engine_02
[], //fx_particle_engine_03
[], //fx_particle_engine_04
[], //fx_particle_pow_01
[], //fx_particle_pow_02
[], //fx_particle_pow_03
[], //fx_particle_ratata_01
[], //fx_particle_ratata_02
[], //fx_particle_ratata_03
[], //fx_particle_ratata_04
[], //fx_particle_ratata_05
[], //fx_particle_ratata_06
[], //fx_particle_ratata_07
[], //fx_particle_shell
[], //fx_particle_smoke_01
[], //fx_particle_smoke_02
[], //fx_particle_smoke_03
[], //ship_enemy_body
[], //ship_enemy_full
[], //ship_enemy_gun
[], //ship_enemy_wing
[], //ship_giant_body
[], //ship_giant_engine
[], //ship_giant_floor
[], //ship_giant_full
[], //ship_giant_head
[], //ship_giant_roof
[], //ship_jet_body
[], //ship_jet_engine
[], //ship_jet_exhaust
[], //ship_jet_full
[], //ship_jet_gun
[], //ship_jet_head
[], //turret_enemy_base
[], //turret_enemy_full
[] //turret_enemy_gun
],
"sprites": {
"button":[0],
"button_active":[1],
"button_hover":[2],
"character_evil":[3],
"character_hero":[4],
"fx_particle_bomb":[5],
"fx_particle_boom_01":[6],
"fx_particle_boom_02":[7],
"fx_particle_boom_03":[8],
"fx_particle_bullett":[9],
"fx_particle_crash_01":[10],
"fx_particle_crash_02":[11],
"fx_particle_crash_03":[12],
"fx_particle_crash_04":[13],
"fx_particle_engine_01":[14],
"fx_particle_engine_02":[15],
"fx_particle_engine_03":[16],
"fx_particle_engine_04":[17],
"fx_particle_pow_01":[18],
"fx_particle_pow_02":[19],
"fx_particle_pow_03":[20],
"fx_particle_ratata_01":[21],
"fx_particle_ratata_02":[22],
"fx_particle_ratata_03":[23],
"fx_particle_ratata_04":[24],
"fx_particle_ratata_05":[25],
"fx_particle_ratata_06":[26],
"fx_particle_ratata_07":[27],
"fx_particle_shell":[28],
"fx_particle_smoke_01":[29],
"fx_particle_smoke_02":[30],
"fx_particle_smoke_03":[31],
"ship_enemy_body":[32],
"ship_enemy_full":[33],
"ship_enemy_gun":[34],
"ship_enemy_wing":[35],
"ship_giant_body":[36],
"ship_giant_engine":[37],
"ship_giant_floor":[38],
"ship_giant_full":[39],
"ship_giant_head":[40],
"ship_giant_roof":[41],
"ship_jet_body":[42],
"ship_jet_engine":[43],
"ship_jet_exhaust":[44],
"ship_jet_full":[45],
"ship_jet_gun":[46],
"ship_jet_head":[47],
"turret_enemy_base":[48],
"turret_enemy_full":[49],
"turret_enemy_gun":[50]
}
};
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);
}());