Does a line contain a point

后端 未结 3 1898
野趣味
野趣味 2020-12-21 17:00

I want the user to be able to drag the edges of a square around the canvas. With my current solution it works but has glitches, sometimes an edge cannot be selected. Is ther

3条回答
  •  攒了一身酷
    2020-12-21 17:28

    You could define 8 Rect to check against - the 4 sides and 4 corners (so you can move 2 edges at once). The lines of the edge should have a width for the touchable area.

    Define a Point centred on your touch event, there are then methods for checking if a rect contains a point.

提交回复
热议问题