【发布时间】:2021-05-22 00:58:27
【问题描述】:
我正在尝试验证无论如何都会发生这种情况,并且无法绕过它。 createjs 使用这种架构对我来说似乎很愚蠢。但我注意到从现有画布元素创建舞台会从画布中删除所有形状、文字等?代码如下:
html:
<canvas id="canvas" width="800" height="400"></canvas>
js:
var canv = document.getElementById("canvas");
var stage = new createjs.Stage(canv);
var ctx = canv.getContext('2d');
ctx.beginPath();
ctx.arc(50,50,10,0,2*Math.PI);
ctx.stroke();
createjs.Ticker.addEventListener("tick", tick);//circle created is overwritten here!!!?! Why createjs!?
//stage.update();
createjs.MotionGuidePlugin.install();
var shape1 = new createjs.Shape();
shape1.graphics.f("#000000").dc(0,0,10);
var path1 = new createjs.Shape();
path1.graphics.beginStroke("#ff0000").mt(0,0).qt(50,100,100,0);
stage.addChild(path1, shape1);
createjs.Tween.get(shape1).to({guide:{ path:[0,0, 50,100, 100,0] }},2000, createjs.Ease.cubicInOut);
function tick(event) {
stage.update();
}
这是无法绕过的吗?对我来说,createjs 不会只是实际使用未擦除的现有元素,这对我来说似乎很愚蠢。如果不是,那么首先传入一个元素有什么意义,为什么不只是创建一个画布元素并给你ID?无论如何,如果事情是这样,不幸的是,我将不得不去其他地方。很遗憾,因为 createjs 似乎很有用。
【问题讨论】:
标签: javascript createjs