create multiple draggable circles in canvas

后端 未结 2 535
时光说笑
时光说笑 2021-01-16 10:10

I\'m having trouble with making several circles in a HTML canvas draggable. I don\'t really know what I\'m doing wrong. Hope someone can point out my mistakes (rookie here s

2条回答
  •  悲&欢浪女
    2021-01-16 10:46

    There is a error here!

    //no circle currently focused check if circle is hovered
    for (var i = 0; i < circles.length; i++) {
        if (intersects(circles[i])) {
            circles.move(i, 0);
            focused.state = true;
            break;
        }
    }
    draw();
    

    You need to use

    cicles.move(i,i)

提交回复
热议问题