我有一个图片列表,我想将它们添加到容器中以便将它们添加到动画功能中以优化我的代码我使这个数组添加所有它们一次但问题是我怎么能在这种情况下选择对象或容器?我想访问包含图像的容器,以便在其上应用补间。
var containers = {};
var bitmaps = {};
var arrayOfThings = [
{ target: 'Ace', x: 90, y: 148, width: 276, height: 266},
{ target: 'K', x: 376, y: 148, width: 276, height: 266},
{ target: 'Q', x: 662, y: 148, width: 276, height: 266}
];
arrayOfThings.forEach(function(thing) {
var target = thing.target;
var bm = bitmaps[target] = new createjs.Bitmap(loader.getResult(target));
var container = containers[target] = new createjs.Container();
container.addChild(bm);
container.x = thing.x;
container.y = thing.y;
container.width = thing.width;
container.height = thing.height;
stage.addChild(container);
});