在 StageGL 上下文中使用过滤器和精灵时出现问题

Problem using Filters and Sprites in a StageGL context

首先,对不起我的英语。

我正在使用 CreateJS 库上的 WebGL 处理一些精灵。我需要在用于创建 spritsheet 的 jpg 上应用自定义颜色过滤器。

这是我的代码:

let bmp = new createjs.Bitmap(rscTexture);
bmp.filters = [new createjs.AlphaFilter()];
bmp.cache(0, 0, rscTexture.width, rscTexture.height, {1, useGL:"stage"});

let frames = this.generateFrames();
this.sprite = new createjs.Sprite( new createjs.SpriteSheet({
  framerate:  24,
  "images": [bmp.cacheCanvas],
  "frames":  frames,
  "animations": {
    "run": [0, frames.length - 1],
  }
}));

问题是这行下一个错误:

ERROR Cannot use 'stage' for cache because the object's parent stage is not set, please addChild to the correct stage.

如果我还没有创建元素,如何先将元素添加到舞台?

如果您有一个已经存在的 StageGL 实例,您可以直接传入它。 "stage" 捷径试图找出答案;但是,有时您需要具体说明,直接传递引用是唯一的解决方案。

bmp.cache(0, 0, rscTexture.width, rscTexture.height, 1, { useGL: myStage });

具体和完整的文档可以在这里找到: https://createjs.com/docs/easeljs/classes/BitmapCache.html#method_define