在 createjs 上使用 EaselJS 将 child 添加到舞台时出错 - a.dispatchEvent 不是函数

Error adding child to stage with EaselJS on createjs -- a.dispatchEvent is not a function

我正在使用 createjs 套件和 JQuery。
当我尝试将 child 添加到舞台时,控制台会出现以下错误:

这是写的代码:

function intro(stageProperties) {
  console.log('Playing Intro');
  console.log(stage);
  console.log($CANVAS_W);

  let background = new createjs.Graphics();
  background.beginFill('black');
  background.drawRect($CANVAS_W,$CANVAS_H);
  stage.addChild(background);

  runTicker();

  // Draw company plaque and game title
  setTimeout(function(){
    instructions();
  },1000 * 5)
};

我已经尝试做这个 运行 很长时间了,但我不知道我做错了什么。

我已经看到 createjs 套件和 JQuery 之间可能存在冲突,但我仍然无法弄清楚。

您不能将图形直接添加到舞台。图形定义如何绘制 Shape 的内容。它们也可以在 Shape 实例之间共享。

您需要将 Graphics 包装在 Shape 实例中,然后将其添加到舞台中:

var shape = new createjs.Shape(background);

干杯。