【发布时间】:2014-07-22 14:05:24
【问题描述】:
我对 Kinetic JS 还很陌生。 我试图让一些 .globalCompositeOperation 在我拥有的项目的两个部分中工作,我尝试了几种可以在这里找到的解决方案,使用“drawFunc”和“sceneFunc”等......但到目前为止还没有运气。
项目的一部分我试图让“目的地”在 kinetic.Sprite 上工作:
var strokesSprite = new Kinetic.Sprite({
image: e,
animation: 'intro',
animations: {
'intro': config.spritestrokes.frames
},
frameRate: 7,
frameIndex: 0,
sceneFunc: function (ctx) {
ctx.save();
ctx.globalCompositeOperation = 'destination-out';
ctx.restore();
}
var strokes = new Kinetic.Layer({
width: 1280,
height: 1280,
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
offset: {
x: 1280 / 2,
y: 1280 / 2
}
});
strokes.add(backgroundPainted);
strokes.add(strokesSprite);
strokes.draw();
stage.add(strokes);
"backgroundPainted" 是 Kinetic.Image
不幸的是,我在这里得到的只是精灵图层在“backgroundPainted”之上进行动画处理,但没有应用复合操作:(。
对于我的第二个实例,它实际上非常相似,我只有 2 个图层,都在里面有形状,添加到舞台上。我将相同的“sceneFunc”应用到顶部的图层,然后绘制它们。 两个图层都显示,没有应用合成。 :(
关于我应该看什么的任何指示?我看到例如“drawFunc”最近已更改为“sceneFunc”,也许还有其他一些变化,因为我已经尝试了几乎所有可以在堆栈上找到的示例。
谢谢
【问题讨论】:
标签: javascript canvas kineticjs composite globalcompositeoperation