如何用easeljs-0.8.0.js画一条线?(createJs)

时间:2015-02-10 10:39:12

标签: javascript html5 canvas createjs

人。我使用easeljs-0.8.0.js绘制一条线,但它不起作用,你能帮助我吗?

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="lib/easeljs-0.8.0.js"></script>
</head>
<body>
<canvas id="demoCanvas" width="1200" height="600"></canvas>
</body>
<script>
window.onload = function() {
    var canvas = document.getElementById("demoCanvas");
    var stage = new createjs.Stage(canvas);
    var lineShape = new createjs.Shape();
    lineShape.graphics.moveTo(10,10).setStrokeStyle(1).beginStroke("#ff0000").lineTo(50,50);
    stage.addChild(lineShape);
    stage.update();
}
</script>
</html>

我无法用上面的代码画一条线!!!

1 个答案:

答案 0 :(得分:2)

在0.8.0中,图形引擎被重写,您现在需要在moveTobeginStrokebeginFill后调用beginStrokeStyle,因为这些方法和#34 ;重置&#34;路径。

请参阅:https://github.com/CreateJS/EaselJS/issues/520