# How do i measure travelled distance of a single object

Get help using Construct 2

### » Fri Oct 09, 2015 8:59 pm

In my game the players use touch to move a ball around.

There is an event:

on any touch end > apply physics force (acceleration) at angle Touch.AngleAt(0) at image point 0

but if the player accidentally tap on the sreen or the swipe movement is weak the ball barely moves, i wish that in both cases it didn't count as a move, and the player being able to try again without loosing his turn.

If i could measure the travelled distance of the ball, or compare the object position before and after the touch i could solve this problem.

I know that bullet behavior has this expression (travelled distance), but this behavior don't fit on my game purposes. Is there a way to measure the travelled distance of the ball?

Thanks.
B
14
S
5
Posts: 110
Reputation: 1,338

### » Fri Oct 09, 2015 10:11 pm

artbava wrote:If i could measure the travelled distance of the ball, or compare the object position before and after the touch i could solve this problem.

I know that bullet behavior has this expression (travelled distance), but this behavior don't fit on my game purposes. Is there a way to measure the travelled distance of the ball?.

System expressions

........-II-..........StartY

On Touch start.. Set StartX to Ball.X
.............................Set StartY to Ball.Y

On Touch end...
..System compare two values: distance(StartX.StartY,Ball.X,Ball.Y)>some value...do something
Else...do something else..

..but
...I think the better solution would be to compare distance between Touch Start X,Y and Touch End X,Y....
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

### » Sat Oct 10, 2015 12:26 am

Korbaach,

Thank you very much for this nice and good looking answer! I really appreciated! Will help me a lot!

I just don't get the
..but
...I think the better solution would be to compare distance between Touch Start X,Y and Touch End X,Y....

Do they not refer to the same procedure?
........-II-..........StartY

On Touch start.. Set StartX to Ball.X
.............................Set StartY to Ball.Y

On Touch end...
..System compare two values: distance(StartX.StartY,Ball.X,Ball.Y)>some value...do something
Else...do something else..

I'm sorry, did i miss something?

Regards!
B
14
S
5
Posts: 110
Reputation: 1,338

### » Sat Oct 10, 2015 12:44 am

same...but instead of Ball, you compare touch X & Y

edit:

I set force to distance*2

so..if distance is 100 ;force=200..d=150;force=2*d...
..Of course you can set force whatever you want..this is just example..
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

### » Sat Oct 10, 2015 1:33 am

Wow! You are awsome!

Thank you very much for your time and dedication! This is really very kind of you!

Best wishes!
B
14
S
5
Posts: 110
Reputation: 1,338