Curved swipe motions
I've got a game that involves swiping a ball to make it move in whatever direction you swipe.
I have an actor that covers the whole scene and it has a rule that fires when touch is pressed, recording the x and y position where the touch started. The ball actor has a rule that says when the mouse is over the object, move it in the direction of the swipe. I'm using vectorToAngle with the position where the touch started and the position of the ball.
This seems to work fine for straight swipes. The problem is with curved swipes. The ball moves in the direction of a straight line from the starting touch position to the ball, but that doesn't always match the direction the swipe was going when it hit the ball.
Imagine you touched the screen directly to the right of the ball, then moved your finger down below the ball, then up towards the ball. With my technique, the ball is going to move left, even though intuitively, it should move up. Make sense?
Any better strategies for handling this?
Is there any way to determine what direction a swipe was going right before it hit the ball instead of just using the start and end point?
I have an actor that covers the whole scene and it has a rule that fires when touch is pressed, recording the x and y position where the touch started. The ball actor has a rule that says when the mouse is over the object, move it in the direction of the swipe. I'm using vectorToAngle with the position where the touch started and the position of the ball.
This seems to work fine for straight swipes. The problem is with curved swipes. The ball moves in the direction of a straight line from the starting touch position to the ball, but that doesn't always match the direction the swipe was going when it hit the ball.
Imagine you touched the screen directly to the right of the ball, then moved your finger down below the ball, then up towards the ball. With my technique, the ball is going to move left, even though intuitively, it should move up. Make sense?
Any better strategies for handling this?
Is there any way to determine what direction a swipe was going right before it hit the ball instead of just using the start and end point?
Answers