Easel无法在容器的递归克隆中克隆bmp

时间:2018-04-12 03:59:38

标签: createjs

使用EaselJS v 1.0.0,当使用LoadQueue预加载图像时,看起来在父容器上的递归克隆期间无法克隆它们。

例如:

function test() {

  const { Bitmap, Container, LoadQueue, Shape, Stage, Ticker } = createjs

  function loadImage () {
    const queue = new LoadQueue()
    queue.addEventListener("fileload", addImage)
    queue.loadFile("image.jpg")
  }

  function addImage (e) {
    const image = e.result

    const bmp = new createjs.Bitmap(image)
    const cnt = new Container()
    cnt.addChild(bmp)

    const cnt2 = cnt.clone(true)
    cnt2.x = 200

    mainCnt.addChild(cnt, cnt2)

    stage.update()
  }

  const stage = new Stage(document.getElementById('test'))
  const mainCnt = stage.addChild(new Container())

  loadImage()
}

以上导致异步GET在EaselJS#Bitmap.js中尝试在Bitmap的克隆方法中执行cloneNode时失败:

image = image.cloneNode();

当它在src是blob的节点上运行image.cloneNode()时,会导致异步错误。

我可以在每次需要时使用缓存来解决这个问题,但我正在更新一个相当大的游戏存储库(数百个),它基于Easel 0.6构建,有很多这样的实例。

任何人都知道有任何解决方法吗?

0 个答案:

没有答案
相关问题