我一直在使用CreateJS。我无法加载由Texture Packer制作的图像,我得到了这样的JSON文件:
{"frames": [
{
"filename": "aim_dot",
"frame": {"x":118,"y":4,"w":76,"h":76},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":76,"h":76},
"sourceSize": {"w":76,"h":76}
},
{
"filename": "boundary",
"frame": {"x":4,"y":385,"w":250,"h":100},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":250,"h":100},
"sourceSize": {"w":250,"h":100}
}]
}
当Bitmap代表这样的图像时:
var bitmap = new createjs.Bitmap("imagePath.jpg");
但如果图像是精灵图像,我可以使用像css sprite这样的位图吗?
答案 0 :(得分:1)
您应该查看SpriteSheet
- 类:http://www.createjs.com/Docs/EaselJS/classes/SpriteSheet.html
在TexturePacker中,您可以选择EaselJS作为输出格式,因此JSON可以用于EaselJS SpriteSheet
而无需进一步修改。另一个生成EaselJS SpriteSheets的好方法是spritesheet.js(https://www.npmjs.com/package/spritesheet-js-monkiki-fork)。