画架使用多个图像进行动画制作

时间:2016-02-13 10:02:32

标签: javascript createjs easeljs

是否有人可以建议是否有方法为不同的动画加载不同的图像,例如。 "空闲","眩晕","拍摄"?

var data = new createjs.SpriteSheet({
    "images": ["images/Drones-Hovering-Loop-12fps.png"],
    "frames": {"regX": 0, "height": 262, "count": 25, "regY": 0, "width": 250},
    "animations": {
      "idle": [0, 24],
      "stun": [0, 0]
    },
    framerate: 24
  });
  drone = new createjs.Sprite(data, "idle");

1 个答案:

答案 0 :(得分:3)

您可以通过提供扩展的frames数组来实现此目的:

var data = new createjs.SpriteSheet({
  "images": ["images/Drones-Hovering-Loop-12fps.png", "image2.png"],
  "frames": [
    // x, y, width, height, imageIndex*, regX*, regY*
    [0, 0, 250, 262, 0, 0, 0],
    [0, 0, 250, 262, 1, 0, 0]
    //...
  ],
  "animations": {
    "idle": [0, 24],
    "stun": [0, 0]
  },
  framerate: 24
});
drone = new createjs.Sprite(data, "idle");

imageIndex(帧数组中的第5个元素)是指定图像源所需的内容。在我的示例中,#0是images/Drones-Hovering-Loop-12fps.png,#1是image2.png

链接到文档:http://createjs.com/docs/easeljs/classes/SpriteSheet.html