On-screen joystick with libgdx, boundary stops?

Hi all, I am new to java and libgdx and maths come to think of it! I am trying to make an on-screen joystick for the android side of life. So far I have drawn a filled circle and another smaller filled circle at the same centre coordinates. I have the thumb circle moving around in regards to mouse and touch, with ‘touchDragged’ and resetting the thumb to centre with ‘touchUp’.

At this point I am stuck! I can use .dst to find the distance between the centre points(vector2) and the thumb circle(vector2) and I can find the angle 0 - 360 from the x line. But how can I set the bounds and no the x and y coords so you can’t move the thumb circle outside the bounds of the larger background circle.

I think the solution involves soh cah toa but my limited math skills are letting me down. Can anyone point me in the right direction please I have been trawling the internet with limited success.

Many thanx in advance

Darren

Here, look at this for collisions:

Maybe looking at the sources of my joystick example helps: joystick

Opiop65 you are a gentleman and a squire…that was perfect. Lots of theory their and things to learn.

65k…looking now. Ok maybe not…the link is broken page will not load.

Sorry, fixed the link.

You can always thank me with a medal ;D

If I new how I would do…

Hit the “appreciate” link above his post. 8)