Making Your Finger a Joystick in Gamesalad?
Hello ![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
I have a game where i use a joystick to control a ball around the screen. However, the joystick really gets in the way of the game...so i want to make it so that the screen IS the joystick. What i mean by that if you move your finger upright, down, or any direction on any part of the screen, the ball will do the same. This way the controls for my game will be a ton easier. Does anyone know how i can do this? Thanks!
![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
I have a game where i use a joystick to control a ball around the screen. However, the joystick really gets in the way of the game...so i want to make it so that the screen IS the joystick. What i mean by that if you move your finger upright, down, or any direction on any part of the screen, the ball will do the same. This way the controls for my game will be a ton easier. Does anyone know how i can do this? Thanks!
![:) :)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/smile.png)
Comments
all you have to do is
when your touch count = 1 record the initial location of the touch.
find the offset of the ball from the touch then constrain the touch to x and y of the ball plus the offset.
I used this idea for a targeting game Im working on.
when touch = 1
change initialX to touch.1.x
change initialY to touch.1.y
change offsetX to initialX - ball.position.x
change offsetY to intialX - ball.position.y
constrain ball.position.x to touch.1.x + offsetX
constrain ball.position.y to touch.1.y + offsetY
notice the changes have to happen everytime the finger initally is down.
you can also make it move faster than the finger by multiplying the contrains by 2 or 3 or 4 (i.e. (touch.1.x + offsetX)*4)
hope that helps