How do I measure how many pixels are moved?

0 favourites
  • 8 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • I have seen that the Bullet Behaviour can do that, I think.

    But I have a platform behaviour without bullet behaviour.

    I would want: when player jumps, show on the screen how high the player is.

    Is this possibily built in?

    I have tried distance(x1,y1,x2,y2), but I think I do not understand how to use this command, or I can not use this command to get the result I want.

  • Yes use distance.

    x1,y1 are for the initial position of you object, x2,y2 are for the the final position.

    So all you have to do is to store this values into some variables, for example at jump start for x1y1 and when your object start falling for x2y2 then use the distance function.

  • Thanks, I understand.

    My problem is how to measure the Y-distance traveled at every tick. (you mentioned to use an event like jumping or falling, that is not what I have in mind)

    I tried:

    every tick: store Y into variable1.

    every tick: store Y into variable2.

    If variable1>variable2 (meaning: object is moving upwards): add (variable1-variable2) to VariableTraveled.

    Result: variable1 and variable2 were always the same. VariableTraveled remained 0.


    As in the game doodle jumper: how far have you traveled upwards?

    Or: During a level a balloon (platform behaviour, no bullet behaviour) gradually moves upwards and I want to display how many meters the balloon has traveled.

    I expected: every change in Y-movement

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well can you provide a simple capx, I'll try to have a look on it ?

  • The way you did you're making both variables the same value

    Try making variable1 the Y value when the layout starts, and variable2 the Y value every tick.

    Variable2-Variable1 will give you the distance traveled

  • Joskin: I will as soon as I can. Thanks.

    7Soul: good suggestion, but I would want to add up Y-distance traveled with every jump the object makes. And the object can fall down. So after 3 jumps, the player stand on the same place as when the layout started, but I would want (as statistic) show how much Y-upwards it has traveled.

  • While jumping add dt (delta time) * X to a variable ?

  • Joskin I am guessing this will do: count how much time passes * X and you have a value that keeps increasing when you jump?

    If so, that would be a solution to me. I will try this as soon as I can.


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