Swiping diagonally
michaelpane13
Member Posts: 2
Hi there,
I am developing a game in which the user is able to move a character up, down, left, right, and diagonally.
However, I cannot figure out how to move the character diagonally. Do any of you know how to do this? I will tip anyone who is able to help me figure this out. Thanks a ton.
Comments
What kind of tip are we talking about, I need to know the numbers before I move on this one.
Swipe diagonally . . . .
Record the first touch, then a fraction of a second later record the current position of the touch . . . use Vector to angle to determine the angle . . . then have a rule that checks that this angle is within a range (i.e. if angle is > 20 and < 80)
Do you mind adding my Skype so I can explain? Skype: csmikepane
Thanks for the replies by the way.. you're the man
I don't use Skype ! Also I'm not really for the exchange of information being taken away from the forum for various reasons.
Completely understandable! I'm making a game where a character dashes through tunnels. I'm very new to Game Salad, but I managed to learn how to swipe left right up and down through a video. The video did not describe how to do the diagonal directions so I'm coming here.
Make two 'real' attributes in an actor, call them something like swipeX and swipeY and a third 'angle' attribute, let's call that one 'swipeAngle'.
. . . . . . . .
Place a rule in the actor that says . . . when mouse button is down change swipeX to mouse positionX - and change swipe Y to mouse position Y.
This records the X and Y positions of where you initially touch the screen.
. . . . . . . . .
Then have a timer that says . . . after 0.2 seconds (adjust to taste)
Change swipeAngle to . . . vectorToAngle (swipeX - mouseX, swipeY - mouseY)
This works out the angle between where you initially touched the screen and where your touch is currently (0.2 seconds later).
. . . . . . . . . .
Use this value (swipeAngle) to do stuff !!
i.e. If swipeAngle is >20 deg and <70 deg then move diagonally (up/right) . . . . etc etc
You could try our free 8 way joystick template, its an old one but should help.
http://www.deepblueapps.com/8-way-controller-template/