Activity_Touch : Determine direction

Spacewalker

Member
Licensed User
Longtime User
Hello,

newbie question (I think) :
I need to determine in which direction (left, right, up, down) a lable is dragged (moved) using Activity_Touch.

I was thinking of analyzing the change of the label's x,y position in Activity_Touch, something like

if lastX - x <0 then lable_was_moved_left
if lastX - x >0 then lable_was_moved_right
if lassY - y <0 then lable_was_moved_up
if lastY - y >0 then lable_was_moved_down
(maybe checked in a timer...)

Is this the best way to do it ?
But what if the label is dragged left..but a bit down, too ? So the "main"-direction is left...
I'd need some of a "trembling compensation"
Is using angles a good idea? So for example dragging left ist 0 degree, up 90 degree,left 180 degree and down 270%?
Then I'd need to calculate the angle of the dragging..how could I do that?

Heinz
 

Spacewalker

Member
Licensed User
Longtime User
Take a look at ...

thanks for the link.

The code there will work for left and right movements.
And I could add code for up and down.

But:
If I move the object not 100% horizontally or vertically but diagonal (change X and Y position) - then I will get "moved left" and "moved up" at the same time.

I need either "moved up" or "moved down" depending on what was the "strongest" direction.

Heinz
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It would be easier to help you if you told us what exactly you want to do before speaking of code.
Or if you already have some code post the project as a zip file (IDE menu Files / Export As Zip) and explain what it should do , what you have done and what doesn't work as you expect.

Best regards.
 
Upvote 0
Top