iOS Joystick question

B

batmanai15

Guest
I have a working left touch joystick working for player movement in my game.

What I’m finding is that if I lift my thumb then go to place it again periodically I may be just outside the touch zone and it doesn’t sense it.

Is it possible to have the joystick recreate itself with the center being where my thumb touches the screen? As almost anywhere on the left side of the screen the joystick could be created where I place my thumb.
 

JackTurbo

Member
Not dealt with touch controls myself so this might not be perfect but I think it should be relatively straight forward.

Store mouse x/y coords on first touch in a pair of variables. Then while the touch is still happening use length_dirx/y between the stored coords and the current coords. Divide these by the radius of the ring of your virtual joy stick and clamp the result between -1 and 1 and that should give you results similiar to a normal analogue stick.
 
B

batmanai15

Guest
This method wouldn’t actually draw the joystick to the screen though would it....
 
Top