computeVelocity(axis, body, velocity, acceleration, drag, max) → {number}
A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
Based on a function in Flixel by @ADAMATOMIC
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
axis | number | 0 for nothing, 1 for horizontal, 2 for vertical. | ||
body | Phaser.Physics.Arcade.Body | The Body object to be updated. | ||
velocity | number | Any component of velocity (e.g. 20). | ||
acceleration | number | Rate at which the velocity is changing. | ||
drag | number | Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. | ||
max | number | <optional> | 10000 | An absolute value cap for the velocity. |
Returns
number -
The altered Velocity value.
- Source code: physics/arcade/World.js (Line 257)
Please login to continue.