http://codepen.io/haikudoichi/pen/OPYBQN
除了删除选项外,一切似乎都有效。当我点击圆形对象时,我希望能够删除它。然而,它表现得很时髦。
这是对的吗?
var sqrt = Math.sqrt((this.x - x)^2 + (this.y - y)^2);
答案 0 :(得分:2)
我想你想这样做:
var sqrt = Math.sqrt(Math.pow(this.x - x, 2) + Math.pow(this.y - y, 2));
^
是Bitwise XOR运算符。
答案 1 :(得分:0)
“ ^ ”不起作用,试试这个:
var sqrt = Math.sqrt(((this.x - x) * (this.x - x)) + ((this.y - y) * (this.y - y)));