- Thu 3 Jan 2019, 17:04
is it possible to achieve like the button move to right or left
Actually it doesn't necessary to control character with a button movement.
Pick a base sprite, either an invisible or the circle for example.
Pick the center point of this base and move the character by taking in to account the position of the touch compared to the center position of this base as I explained.
End then, only as a visual effect, add the button and make it move left and right based on how much the user move the pointer left and right by taking in to account the distance between the center point of the base and the position of the touch.
So for example if the touch is 40 pixels from the center, move the button 40 pixels to the right but obviously use a variable that constantly store the current distance then apply It on the button...
You also want to implement some sort of limit too so the player can not drag the button all over the screen and stop at the edge of the circle for example.
I don't have time right now to update the example if no one else come up with an example for you I'll do it when I have time later.