hlissnake Posted March 1, 2014 Report Share Posted March 1, 2014 as we know. Object veloctiy will be change by acceleration such as gravity and velocity = Acceleration x time, and gravity accelerate constant is 9.81 in our real world. but I don't understand the gravity value in phaser phyics system, so, can you just show how sould I calculate object move time by the phaser gravity. it is different from real world gravity Quote Link to comment Share on other sites More sharing options...

Magnifisite Posted March 1, 2014 Report Share Posted March 1, 2014 In real life the gravity is 9.81 m/s^{2 }and that means the velocity will be 9.81 m/s greater every second, in phaser you could say that the gravity is pixels per tick per tick.To calculate the time that it takes to move from point A to B is quite "hard" in games because the speed is in pixels per tick and the time of 1 tick is variable.I'm not entirely sure how many ticks per second Phaser but I think it uses 60 ticks per second.If 1 pixel in your game represents 1 meter then your Y gravity should be 588.6 pixel/second. To calculate the time it takes for an object to fall you have the equation t = sqrt(2 * distance / g) so in this case t (in seconds) = sqrt(2 * distance / 588.6). Quote Link to comment Share on other sites More sharing options...

hlissnake Posted March 1, 2014 Author Report Share Posted March 1, 2014 In real life the gravity is 9.81 m/s^{2 }and that means the velocity will be 9.81 m/s greater every second, in phaser you could say that the gravity is pixels per tick per tick.To calculate the time that it takes to move from point A to B is quite "hard" in games because the speed is in pixels per tick and the time of 1 tick is variable.I'm not entirely sure how many ticks per second Phaser but I think it uses 60 ticks per second.If 1 pixel in your game represents 1 meter then your Y gravity should be 588.6 pixel/second. To calculate the time it takes for an object to fall you have the equation t = sqrt(2 * distance / g) so in this case t (in seconds) = sqrt(2 * distance / 588.6).thank you. finally I use body.accelerate.y to instead of Gravity in game. the speed is not like you say per pixies per tick. in phaser it's show as the velocity per second, and that may be nearly 60 tick in each second, not excatlty. but allmost. so we must use velocity multiply tick time to get the translate in this tick. gravity value in phaser is not clear to understand. eg: I use velocity.y = 1800 to emulate gravity 30. when object jumping in air. I gave it -600 velocity above. and the falling effect is almost prefect Quote Link to comment Share on other sites More sharing options...

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.