How do i measure travelled distance of a single object

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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.

  • 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

    add variable StartX

    ........-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....

  • 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 [quote:21z4b7qh]..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? [quote:21z4b7qh]add variable StartX

    ........-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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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..

  • Wow! You are awsome!

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

    Best wishes!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)