Copy link to clipboard
Copied
Hello,
I'm trying to solve a problem where I have one circle following another ( the first following the mouse ), yet maintain a minimum distance between the two circles.
The code is pretty simple. For the lead circle I'm moving it as follows on the movement of the mouse:
circle.x = event.stageX + 8.000000E-001 * ( circle.x - event.stageX );
circle.y = event.stageY + 8.000000E-001 * ( circle.y - event.stageY );
Then I'm moving the secondary circle as:
circle2.x = circle.x + 8.000000E-001 * ( circle2.x - circle.x );
circle2.y = circle.y + 8.000000E-001 * ( circle2.y - circle.y );
This works remarkably well, however, I want to be able to increase the distance between the two circles and enforce a minimum. If anyone can point me in the right direction I'd appreciate the assistance. Thanks.
Copy link to clipboard
Copied
increase .008 to increase the distance and use if-statements to enforce a minimum.
Copy link to clipboard
Copied
Thanks for responding. To what are you referencing that I increase by .008, not following? Thanks.
Copy link to clipboard
Copied
that was supposed to be .8
Find more inspiration, events, and resources on the new Adobe Community
Explore Now