我试图通过鼠标点击更改画布上一条线的位置。它应检测第一次单击并从单击鼠标位置更改结束坐标。我似乎无法更改点击功能的结束坐标值。
<script language="javascript" type="text/javascript">
var canvas = oCanvas.create({
canvas: "#myCanvas",
background :"#808080"
});
var line = canvas.display.line({
start: {x:80, y:60},
end: {x:280, y:170},
stroke: "10px #0aa",
cap: "round"
});
canvas.addChild(line);
canvas.bind("click tap", function(){
alert(line.start.x + " " + canvas.mouse.x);
line.end.x = canvas.mouse.x;
line.end.y = canvas.mouse.y;
canvas.redraw;
});
</script>
答案 0 :(得分:0)
您缺少重绘函数调用的括号。添加它,它应该工作。要使它适用于触摸,请使用canvas.pointer.x和canvas.pointer.y。