So I have a line drawn with graphics(). It’s anchored at one end, and the other end is draggable. I made a quick demo here, and so far, so good:
Dragging the marker around and redrawing the line is no problem, but what I’d like is for that line to have a maximum length of 100, so even if you’re still dragging beyond that point, the line would still follow the mouse, but not get any longer than 100. Dragging inside that maximum radius, the line would shrink as normal.
I’ve put together a visual that hopefully explains it:
The issue is that I suspect this is VERY MATHS and I am very, very weak with maths. Could anyone explain like I’m five what I need to do to my code to achieve this? Thank you!
Yes, you are right, it was my answer. I check StackOverflow the phaser discourse for interessting question, which I might be able to answer, if I have some freetime.
Thanks for these, Samme. I had a quick go with limit() (setting it at the point of creation) but it didn’t seem to do anything. But @akumagamo 's answer on SO answered it perfectly. I’ve updated my pen with their code for anyone else who’s looking for this solution: