0

I'd been using CreateJS for a little time. I got trouble to load an image which is made by Texture Packer, and I got the JSON file like this:

{"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}
}]

}

When a Bitmap represents an Image like this:

 var bitmap = new createjs.Bitmap("imagePath.jpg");

But if the image is an image sprites,could i use the bitmap like css sprite?

wuyou
  • 18
  • 4
  • function showStartMenu() { //Method 1 var sprites_0 = { "images": ['image.png'], "animations": { "slice1": {"frames": [0]} }, "frames": [ // x, y, width, height, imageIndex*, regX*, regY* [916, 101, 84, 84, 0, 0, 0] ] }; var spriteslist = new c.SpriteSheet(sprites_0); var slices= new c.Sprite(spriteslist); stage.addChild(slices); slices.gotoAndStop('slice1'); stage.update(); } – wuyou Mar 18 '15 at 07:25

1 Answers1

1

You should take a look at the SpriteSheet-Class: http://www.createjs.com/Docs/EaselJS/classes/SpriteSheet.html

In TexturePacker you can chose EaselJS as a output format, so the JSON can be used for EaselJS SpriteSheet without further modifications. Another good way to generate EaselJS SpriteSheets would be spritesheet.js (https://www.npmjs.com/package/spritesheet-js-monkiki-fork).

derz
  • 732
  • 1
  • 8
  • 18